Fix deadlock on Linux/x64 between SamplingProfiler and VMTraps
Created attachment 360565 [details] Patch
Created attachment 360566 [details] Patch
Created attachment 360568 [details] Patch
There was a deadlock in the following situation: Thread 1 (Sampling): In SamplingProfiler.cpp:takeSample it takes all locks and then tries to suspend the main thread. Thread 2 (Watchdog/VMTraps): Before the Sampling-Thread suspends the main thread a signal is caught and signal handler is invoked (VMTraps.cpp:SignalSender). SignalSender tries to lock codeBlockSet, but this is already locked by the SamplingProfiler. The SamplingProfiler can only give up the lock when it suspends the thread. However since the VMTraps signal handler is active, all other signals blocked, therefore the SamplingProfiler also waits until its signal handler is invoked. The patch fixes this by only blocking all signals except for SIGUSR1, which is used for suspending/resuming threads.
I would add that nice explanation of the deadlock to the ChangeLog, and also mention the flaky test this fixes.
Created attachment 362007 [details] Patch
Comment on attachment 362007 [details] Patch Clearing flags on attachment: 362007 Committed r241583: <https://trac.webkit.org/changeset/241583>
All reviewed patches have been landed. Closing bug.
<rdar://problem/48108626>