Comment 2 for bug 1558206

Revision history for this message
Andrew Johnson (anj) wrote :

Looking at the comments immediately above your addition, I'm not sure whether this is quite the right fix:

    if ( ! waitRelease ) {
        epicsGuard < epicsMutex > guard ( pThread->mutex );
        pThread->terminated = true;
        pThread->exitEvent.signal ();
        // once the terminated flag is set and we release the lock
        // then the "this" pointer must not be touched again
    }
    pThread->pWaitReleaseFlag = NULL;
}

If pThread is the "this" pointer mentioned in that comment (and I'm pretty sure it is), the implication of those comments is that in some circumstances the pThread object may have already been destroyed before the guard's destructor returns. Should the pointer be cleared just before releasing the mutex instead?

The libCom/test/epicsThreadTest.cpp file is not currently a comprehensive test of all supported features of the epicsThread class.