Ticket #14865 (closed defect: fixed)
Data race in wxThreadInternal on Windows
| Reported by: | egor.kazachkov | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | 2.9.5 |
| Component: | wxMSW | Version: | |
| Keywords: | thread | Cc: | |
| Blocked By: | Patch: | no | |
| Blocking: |
Description
Write-Read data race on m_state variable in wxWidgets::thread.cpp (lines 894, 437 for wxwidgets 2.8.12)
Write:
bool wxThreadInternal::Resume()
{
...
// don't change the state from STATE_EXITED because it's special and means
// we are going to terminate without running any user code - if we did it,
// the code in WaitForTerminate() wouldn't work
if ( m_state != STATE_EXITED )
{
m_state = STATE_RUNNING;
}
return true;
}
Read:
THREAD_RETVAL THREAD_CALLCONV wxThreadInternal::WinThreadStart(void *param)
{
THREAD_RETVAL rc = (THREAD_RETVAL)-1;
wxThread * const thread = (wxThread *)param;
// each thread has its own SEH translator so install our own a.s.a.p.
DisableAutomaticSETranslator();
// first of all, check whether we hadn't been cancelled already and don't
// start the user code at all then
const bool hasExited = thread->m_internal->GetState() == STATE_EXITED;
...
}
