Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
fix race condition on m_addr
Browse files Browse the repository at this point in the history
- between pthread_create(&m_addr) and reading m_addr to
  asserting isRunning when adding the newly created thread
- this race existed before but didn't manifest b/c the thread was added
  by the starting thread (after pthread_create) returned
- check isRunning after acquiring slock to ensure pthread_create already
  returned
  • Loading branch information
MartinNowak committed Oct 31, 2015
1 parent e226ff2 commit 20f0350
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/thread.d
Expand Up @@ -1706,12 +1706,12 @@ private:
{
assert( t );
assert( !t.next && !t.prev );
assert( t.isRunning );
}
body
{
slock.lock_nothrow();
scope(exit) slock.unlock_nothrow();
assert(t.isRunning); // check this with slock to ensure pthread_create already returned
assert(!suspendDepth); // must be 0 b/c it's only set with slock held

if (rmAboutToStart)
Expand Down

0 comments on commit 20f0350

Please sign in to comment.