Bug 194014 - Fix deadlock on Linux/x64 between SamplingProfiler and VMTraps
Summary: Fix deadlock on Linux/x64 between SamplingProfiler and VMTraps
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2019-01-30 03:09 PST by Dominik Inführ
Modified: 2019-02-15 05:42 PST (History)
10 users (show)

See Also:


Attachments
Patch (3.27 KB, patch)
2019-01-30 03:11 PST, Dominik Inführ
no flags Details | Formatted Diff | Diff
Patch (3.28 KB, patch)
2019-01-30 03:39 PST, Dominik Inführ
no flags Details | Formatted Diff | Diff
Patch (3.27 KB, patch)
2019-01-30 03:51 PST, Dominik Inführ
no flags Details | Formatted Diff | Diff
Patch (4.25 KB, patch)
2019-02-14 02:45 PST, Dominik Inführ
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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>