[PATCH] Bug #2583 fix: pure virtual method called

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Fri, 20 Aug 2010 16:14:07 -0600

Bug #2583 fix: pure virtual method called

When a cbdata-protected class holds its own cbdata and has virtual
toCbdata(), there is a catch22 problem: we need cbdata to know whether
the pointer to the class object is valid, and we need to dereference
that pointer to get cbdata.

Added CbcPointer class to hold both a pointer to a potentially freed
class object and the cbdata pointer protecting that object. Keeping the
cbdata pointer allows us to test whether the object is still there
without dereferencing the object pointer.

Use the CbcPointer class to hold safe pointers to AsyncJobs. This
prevents "pure virtual method called" failures because we no longer
dereference freed job pointers.

Removed Initiator parameter from many initiatee constructors. The
Adaptation::Initiator::initiateAdaptation method now sets the initiator
of the job. This makes the constructor profile simpler and removes the
need to propagate Initiator changes through all the [nested] constructors.

Renamed AsyncJob::AsyncStart() to AsyncJob::Start(). I had to change the
callers code anyway and it was a good opportunity to remove the
redundant "Async".

Special thanks to Stefan Fritsch for updating and testing an earlier
version of this patch.

-------------------

P.S. The underlying changes have been tested in production but I had to
polish them before submitting to trunk. Some advanced C++ concepts might
not compile on old/broken compilers. We will try to remove/change them
if needed.

P.P.S. This change is required for at least one more bug fix and for the
the 1xx handling patch.

Received on Fri Aug 20 2010 - 22:14:23 MDT

This archive was generated by hypermail 2.2.0 : Sun Aug 22 2010 - 12:00:05 MDT