Bug 194014

Summary: Fix deadlock on Linux/x64 between SamplingProfiler and VMTraps
Product: WebKit Reporter: Dominik Inführ <dominik.infuehr>
Component: New BugsAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, commit-queue, dbates, ews-watchlist, guijemont, mcatanzaro, webkit-bug-importer, ysuzuki
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch none

Description Dominik Inführ 2019-01-30 03:09:51 PST
Fix deadlock on Linux/x64 between SamplingProfiler and VMTraps
Comment 1 Dominik Inführ 2019-01-30 03:11:30 PST
Created attachment 360565 [details]
Patch
Comment 2 Dominik Inführ 2019-01-30 03:39:01 PST
Created attachment 360566 [details]
Patch
Comment 3 Dominik Inführ 2019-01-30 03:51:36 PST
Created attachment 360568 [details]
Patch
Comment 4 Dominik Inführ 2019-01-30 08:12:21 PST
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.
Comment 5 Michael Catanzaro 2019-01-30 11:19:53 PST
I would add that nice explanation of the deadlock to the ChangeLog, and also mention the flaky test this fixes.
Comment 6 Dominik Inführ 2019-02-14 02:45:58 PST
Created attachment 362007 [details]
Patch
Comment 7 WebKit Commit Bot 2019-02-15 05:41:51 PST
Comment on attachment 362007 [details]
Patch

Clearing flags on attachment: 362007

Committed r241583: <https://trac.webkit.org/changeset/241583>
Comment 8 WebKit Commit Bot 2019-02-15 05:41:53 PST
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2019-02-15 05:42:26 PST
<rdar://problem/48108626>