| > Just a little more info -- apparently it was object references which were
> duplicated, and now to release any object reference the code needs to
> loop/repeat releasing until an error message is returned.
Yikes! This is bad programming practice. How do you know
that other pieces of your code are still not holding a pointer
to the object reference? Ie. if you need to do multiple releases
to really release the object then it's likely someone is still
holding a pointer to the object they believe is valid. If not,
then the real bug is that whoever received a duplicate of the
object is not release()ing their copy when they are done with it
(follow your code paths from where-ever you call _duplicate or
_narrow on an object reference, keeping in mind that a successful
_narrow does an implied _duplicate for you).
And so far you are also only lucky that you haven't corrupted
your heap or crashed by calling release() on a pointer to an
object reference that had already been freed by the ORB because
the previous call to release was the one that reduced the reference
count to zero. Ie. on the call to release() that you are getting
an error on, you have passed it a pointer to memory that has
already been returned to the heap (or may have even been returned
to the system if the allocator supports shrinking the heap).
And you are only lucky an error is being detected at all (the
memory has not been re-allocated to someone else and what the
ORB believes is the location of the reference count upon
entry to release() is zero. Also note that the OMG Revision task
force has modified the definition of release() so that it can
no longer throw exceptions, and hence the Environment argument
to release() will likely be deprecated in a future release.
If you are using C++ bindings, you should consider looking at
using the class CORBA::Object_var as an aid in having release()
called automatically on the object reference when the Object_var
instance goes out of scope (as appropriate of course, you don't
want to end up in the opposite of your current situation and
instead release()ing the references too soon).
|