Commit 53e64bb2 authored by Ben Noordhuis's avatar Ben Noordhuis
Browse files

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: https://github.com/nodejs/node/pull/3528


Reviewed-By: default avatarFedor Indutny <fedor@indutny.com>
Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
parent 29da8cf8
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment