[omniORB] Crash on using nil reference

Stephen Crawley crawley@dstc.edu.au
Mon, 14 May 2001 10:30:21 +1000


Tim Ward writes:
> From: Sai-Lai Lo <S.Lo@uk.research.att.com>

> >And how does one retire the mapping of pointers and reference counts?
> 
> One doesn't. It's a static data member in the smart pointer class, so its
> lifetime is the lifetime of the application.
> 
> An entry in the map is deleted when the use count goes to zero; a subsequent
> attempt to decrement the use count will search the map for the pointer, fail
> to find it, and complain that the pointed-to entity has already been
> released.

There is a flaw in this.  The memory manager cannot reallocate the
memory associated with a pointer when its reference count reaches zero.
If it did, you would find that pointers to now dead objects would spring
back into life, pointing at different objects.  This defeats your
checking.  But since the memory manager cannot reallocate freed memory,
it is pretty obvious that the technique leaks memory, and therefore
doesn't scale.

-- Steve