Issue 113679

Summary: bridges: data race in OReaderThread::disposeEnvironment()
Product: udk Reporter: olistraub <openoffice>
Component: codeAssignee: Stephan Bergmann <stephan.bergmann.secondary>
Status: CLOSED FIXED QA Contact: issues@udk <issues>
Severity: Trivial    
Priority: P3 CC: issues
Version: DEV300m84   
Target Milestone: 4.0.0   
Hardware: All   
OS: All   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---

Description olistraub 2010-08-05 12:39:46 UTC
The code in disposeEnvironment() does the following:

If pContext->m_pBridgeImpl->m_bDisposed is FALSE, it calls
pEnvRemote->dispose(...) and pEnvRemote->release()

However, the access to m_bDisposed is not guarded by a mutex. So, even if the
bridge has already started to dispose (RemoteEnvironment_thisDispose() has set
m_bDisposed to TRUE, but m_bDisposed in this thread is still seen as FALSE by
the CPU), the code will walk into the if branch.

On the other hand, if the bridge has already been disposed,
pEnvRemote->release() will never be called.

Wouldn't it be more correct to completely remove the check for m_bDisposed, and
just walk into the if-branch every time?

After doing this change, I also found out that I need to clear the mutex in
RemoteEnvironment_thisDispose() directly after setting the m_bDisposed flag.
Otherwise the OReader thread might deadlock waiting on the mutex, while the
thisDispose() method waits for the thread to finish.
Comment 1 kay.ramme 2010-08-05 13:34:22 UTC
Stephan, please have a look.
Comment 2 Stephan Bergmann 2010-08-09 15:09:46 UTC
.
Comment 3 Stephan Bergmann 2010-12-10 10:39:25 UTC
The relevant code will be obsoleted through issue 116038.
Comment 4 Stephan Bergmann 2011-01-27 10:42:00 UTC
issue 116038 has been fixed
Comment 5 Stephan Bergmann 2011-01-31 14:27:47 UTC
.