Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Issue 415083002: [oilpan]: fix deadlock when leaving a safepoint and sweeping. (Closed)

Created:
6 years, 5 months ago by wibling-chromium
Modified:
6 years, 5 months ago
CC:
blink-reviews, Mads Ager (chromium), abarth-chromium, blink-reviews-wtf_chromium.org, kouhei+heap_chromium.org, Mikhail
Project:
blink
Visibility:
Public.

Description

[oilpan]: fix deadlock when leaving a safepoint and sweeping. In the case where a thread takes a lock/mutex within a safepoint scope and leaves the safepoint with the lock held we risk deadlocking if the same thread takes the same lock in a destructor. The reason is that if another thread did a GC while the first thread was in the safepoint the sweep done by the first thread will potentially call a destructor which could then take the same lock. Since the WTF:Mutex is not recursive/reentrant the thread will deadlock on itself. This change fixes this by introducing a RecursiveMutex which allows a thread to take a lock it is already holding. Interestingly the Windows WTF:Mutex is currently reentrant wrt. the lock() method, but not wrt. tryLock() since tryLock mimics the behavior of the pthread_mutex by keeping a recursion count. To deal with this I introduce a separate tryLock method for the Mutex and the RecursiveMutex that behaves different on windows. On pthreads (Linux/Mac) the tryLock method is identical since it changes behavior depending on how the mutex is created. I have added a test which demonstrates the dead-lock issue. R=ager@chromium.org, erik.corry@gmail.com, haraken@chromium.org, oilpan-reviews@chromium.org, sigbjornf@opera.com, tkent@chromium.org, zerny@chromium.org BUG= Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=178928

Patch Set 1 #

Total comments: 23

Patch Set 2 : review feedback #

Unified diffs Side-by-side diffs Delta from patch set Stats (+234 lines, -48 lines) Patch
M Source/modules/webdatabase/DatabaseBackendBase.cpp View 5 chunks +6 lines, -6 lines 0 comments Download
M Source/platform/heap/HeapTest.cpp View 1 1 chunk +103 lines, -0 lines 0 comments Download
M Source/platform/heap/ThreadState.h View 1 2 chunks +2 lines, -2 lines 0 comments Download
M Source/wtf/ThreadingPrimitives.h View 1 4 chunks +33 lines, -10 lines 0 comments Download
M Source/wtf/ThreadingPthreads.cpp View 1 4 chunks +63 lines, -17 lines 0 comments Download
M Source/wtf/ThreadingWin.cpp View 4 chunks +27 lines, -13 lines 0 comments Download

Messages

Total messages: 12 (0 generated)
wibling-chromium
6 years, 5 months ago (2014-07-24 12:11:18 UTC) #1
sof
The recursive/re-entrant implementations looks correct to me; is there a mutex maven that it'd be ...
6 years, 5 months ago (2014-07-24 21:27:05 UTC) #2
haraken
Looks good, but I also failed in finding a place where guidMutex() is acquired in ...
6 years, 5 months ago (2014-07-25 01:54:41 UTC) #3
tkent
https://codereview.chromium.org/415083002/diff/1/Source/platform/heap/ThreadState.h File Source/platform/heap/ThreadState.h (right): https://codereview.chromium.org/415083002/diff/1/Source/platform/heap/ThreadState.h#newcode621 Source/platform/heap/ThreadState.h:621: explicit SafePointAwareMutexLocker(WTF::MutexBase& mutex, ThreadState::StackState stackState = ThreadState::HeapPointersOnStack) We should ...
6 years, 5 months ago (2014-07-25 05:11:45 UTC) #4
wibling-chromium
Thanks for the reviews! To answer Sigbjorn's and Haraken's question the issue is actually during ...
6 years, 5 months ago (2014-07-25 09:31:29 UTC) #5
tkent
lgtm
6 years, 5 months ago (2014-07-25 09:33:25 UTC) #6
wibling-chromium
On 2014/07/24 21:27:05, sof wrote: > The recursive/re-entrant implementations looks correct to me; is there ...
6 years, 5 months ago (2014-07-25 10:08:57 UTC) #7
sof
On 2014/07/25 10:08:57, wibling-chromium wrote: > On 2014/07/24 21:27:05, sof wrote: > > The recursive/re-entrant ...
6 years, 5 months ago (2014-07-25 10:18:26 UTC) #8
Erik Corry
LGTM https://codereview.chromium.org/415083002/diff/1/Source/wtf/ThreadingPthreads.cpp File Source/wtf/ThreadingPthreads.cpp (right): https://codereview.chromium.org/415083002/diff/1/Source/wtf/ThreadingPthreads.cpp#newcode334 Source/wtf/ThreadingPthreads.cpp:334: // succeed or not for the non-recursive mutex. ...
6 years, 5 months ago (2014-07-25 10:32:38 UTC) #9
wibling-chromium
The CQ bit was checked by wibling@chromium.org
6 years, 5 months ago (2014-07-25 11:03:18 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/wibling@chromium.org/415083002/20001
6 years, 5 months ago (2014-07-25 11:04:21 UTC) #11
commit-bot: I haz the power
6 years, 5 months ago (2014-07-25 11:55:16 UTC) #12
Message was sent while issue was closed.
Change committed as 178928

Powered by Google App Engine
This is Rietveld 408576698