-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: fix race condition in debug signal on exit
Before this commit, sending a SIGUSR1 at program exit could trigger a hard to reproduce race condition where `v8::Debug::DebugBreak(isolate)` got called when the isolate was in the process of being torn down. A similar race condition is in theory possible when sending signals to two threads simultaneously but I haven't been able to reproduce that myself (and I tried, oh how I tried.) This commit fixes the race condition by turning `node_isolate` into a `std::atomic` and using it as an ad hoc synchronization primitive in places where that is necessary. A bare minimum std::atomic polyfill is added for OS X because Apple wouldn't be Apple if things just worked out of the box. PR-URL: #3528 Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
d918838
commit c85736e
Showing
2 changed files
with
60 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef SRC_ATOMIC_POLYFILL_H_ | ||
#define SRC_ATOMIC_POLYFILL_H_ | ||
|
||
#include "util.h" | ||
|
||
namespace nonstd { | ||
|
||
template <typename T> | ||
struct atomic { | ||
atomic() = default; | ||
T exchange(T value) { return __sync_lock_test_and_set(&value_, value); } | ||
T value_ = T(); | ||
DISALLOW_COPY_AND_ASSIGN(atomic); | ||
}; | ||
|
||
} // namespace nonstd | ||
|
||
#endif // SRC_ATOMIC_POLYFILL_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters