
AMDG Phil Bouchard wrote:
"Steven Watanabe" <watanabesj@gmail.com> wrote in message news:481236C2.2040309@providere-consulting.com...
[...]
The problem is that you are manipulating the reference count of a block after it is freed. The first node is deleted. The second node is then deleted which decrements the reference count of the first block which is already deleted.
[...]
Thanks for pointing this out. I dismissed this issue because it this situation the "back" pointer doesn't refer to the first element in the set list after several insertions and this creates a series of problems which may have a solution but better left aside for this type of problem.
I added some code in shifted_ptr::release() which will make it disregard any reference count when the destructor is called upon a set deletion. Now everything works fine.
I'm thinking that the cleanest solution will be to have set deletion split the cleanup into first calling all the objects' destructors and then freeing all the memory. When the objects are destroyed you should increment the reference count to make sure that the objects are not destroyed again. When you actually release the memory you can then verify that the reference count is 1, and thus that all references to the object come from within the set. Otherwise, looking at your current implementation, it looks like shifted_ptr's on the heap will never clean up the object pointed to until the set goes away. In Christ, Steven Watanabe