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

Issue 2041753002: Worker: Protect a running debugger task from forcible worker termination (Closed)

Created:
4 years, 6 months ago by nhiroki
Modified:
4 years, 6 months ago
Reviewers:
kinuko, dgozman
CC:
chromium-reviews, blink-reviews, kinuko+worker_chromium.org, falken, blink-worker-reviews_chromium.org, horo+watch_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Worker: Protect a running debugger task from forcible worker termination A running debugger task must be protected from forcible worker termination, but in the current implementation, there is a corner case where the debugger task can suddenly be killed as follows: 1) performDebuggerTaskOnWorkerThread() is called almost at the same time as terminateInternal() on the main thread. terminateInternal() acquires |m_threadStateMutex| before performDebuggerTaskOnWorkerThread(). 2) terminateInternal() checks a flag |m_runningDebuggerTask| before performDebuggerTaskOnWorkerThread() sets it, schedules a force termination task, and releases the lock. 3) performDebuggerTaskOnWorkerThread() acquires the lock, sets the flag, and runs the debugger task. 4) The scheduled task is fired while the debugger task is running and attempts to terminate it. This may cause crashes. To avoid the case, this CL makes a scheduled task check the flag before terminating the worker execution. In addition, this ensures that postTask() and appendDebuggerTask() don't post new tasks after terminateInternal() or prepareForShutdownOnWorkerThread() is called. BUG=616775 Committed: https://crrev.com/48b51b66bbd7193a56102c49dc2b6ebea67274dc Cr-Commit-Position: refs/heads/master@{#398837}

Patch Set 1 : #

Total comments: 9

Patch Set 2 : add DCHECK #

Total comments: 10

Patch Set 3 : check m_killed in InspectorTaskRunner::appendTask #

Total comments: 2

Patch Set 4 : address review comment #

Total comments: 2

Patch Set 5 : tweak if-condition #

Unified diffs Side-by-side diffs Delta from patch set Stats (+42 lines, -19 lines) Patch
M third_party/WebKit/Source/core/inspector/InspectorTaskRunner.cpp View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/inspector/WorkerInspectorController.cpp View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/inspector/WorkerThreadDebugger.cpp View 1 chunk +2 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/workers/WorkerThread.h View 3 chunks +13 lines, -7 lines 0 comments Download
M third_party/WebKit/Source/core/workers/WorkerThread.cpp View 1 2 3 4 7 chunks +24 lines, -9 lines 0 comments Download

Dependent Patchsets:

Messages

Total messages: 35 (16 generated)
nhiroki
PTAL, thanks!
4 years, 6 months ago (2016-06-06 10:14:32 UTC) #11
nhiroki
FYI: I found another corner case to unexpectedly terminate the running debugger task. I made ...
4 years, 6 months ago (2016-06-07 01:46:16 UTC) #12
kinuko
+dgozman https://codereview.chromium.org/2041753002/diff/100001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2041753002/diff/100001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode235 third_party/WebKit/Source/core/workers/WorkerThread.cpp:235: if (m_terminated || m_readyToShutdown) Do you know if ...
4 years, 6 months ago (2016-06-07 06:04:08 UTC) #15
dgozman
lgtm from inspector side. Thank you for fixing this! https://codereview.chromium.org/2041753002/diff/100001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2041753002/diff/100001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode235 third_party/WebKit/Source/core/workers/WorkerThread.cpp:235: ...
4 years, 6 months ago (2016-06-07 10:25:32 UTC) #16
nhiroki
Thank you for reviewing! Slightly updated. https://codereview.chromium.org/2041753002/diff/100001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2041753002/diff/100001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode235 third_party/WebKit/Source/core/workers/WorkerThread.cpp:235: if (m_terminated || ...
4 years, 6 months ago (2016-06-08 04:19:55 UTC) #17
kinuko
https://codereview.chromium.org/2041753002/diff/100001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2041753002/diff/100001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode342 third_party/WebKit/Source/core/workers/WorkerThread.cpp:342: forciblyTerminateExecution(); On 2016/06/08 04:19:55, nhiroki wrote: > On 2016/06/07 ...
4 years, 6 months ago (2016-06-08 12:43:56 UTC) #18
nhiroki
Thank you! Updated. https://codereview.chromium.org/2041753002/diff/120001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2041753002/diff/120001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode236 third_party/WebKit/Source/core/workers/WorkerThread.cpp:236: if (m_terminated || m_readyToShutdown) On 2016/06/08 ...
4 years, 6 months ago (2016-06-08 16:00:46 UTC) #19
nhiroki
dgozman@, could you take another look? I changed InspectorTaskRunner.cpp after your review. Thanks.
4 years, 6 months ago (2016-06-08 16:02:14 UTC) #20
dgozman
> > Probably kinuko@ does not suggest killing a running debugger task here but > ...
4 years, 6 months ago (2016-06-08 20:53:21 UTC) #21
dgozman
Forgot to public the comment :-) https://codereview.chromium.org/2041753002/diff/140001/third_party/WebKit/Source/core/inspector/InspectorTaskRunner.cpp File third_party/WebKit/Source/core/inspector/InspectorTaskRunner.cpp (right): https://codereview.chromium.org/2041753002/diff/140001/third_party/WebKit/Source/core/inspector/InspectorTaskRunner.cpp#newcode37 third_party/WebKit/Source/core/inspector/InspectorTaskRunner.cpp:37: m_condition.signal(); Let's not ...
4 years, 6 months ago (2016-06-08 20:53:41 UTC) #22
nhiroki
Thank you for reviewing! https://codereview.chromium.org/2041753002/diff/120001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2041753002/diff/120001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode242 third_party/WebKit/Source/core/workers/WorkerThread.cpp:242: if (isolate()) On 2016/06/08 16:00:46, ...
4 years, 6 months ago (2016-06-09 00:01:18 UTC) #23
kinuko
https://codereview.chromium.org/2041753002/diff/120001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2041753002/diff/120001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode236 third_party/WebKit/Source/core/workers/WorkerThread.cpp:236: if (m_terminated || m_readyToShutdown) I see. I wasn't sure ...
4 years, 6 months ago (2016-06-09 00:33:04 UTC) #24
kinuko
https://codereview.chromium.org/2041753002/diff/120001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2041753002/diff/120001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode236 third_party/WebKit/Source/core/workers/WorkerThread.cpp:236: if (m_terminated || m_readyToShutdown) On 2016/06/09 00:33:04, kinuko wrote: ...
4 years, 6 months ago (2016-06-09 00:38:47 UTC) #25
nhiroki
Thank you for your comments! kinuko@, can you review the patchset 4? https://codereview.chromium.org/2041753002/diff/120001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp ...
4 years, 6 months ago (2016-06-09 08:32:05 UTC) #26
kinuko
lgtm. https://codereview.chromium.org/2041753002/diff/160001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2041753002/diff/160001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode244 third_party/WebKit/Source/core/workers/WorkerThread.cpp:244: if (isolate()) nit: or this can be if ...
4 years, 6 months ago (2016-06-09 08:57:42 UTC) #27
nhiroki
Thank you! https://codereview.chromium.org/2041753002/diff/160001/third_party/WebKit/Source/core/workers/WorkerThread.cpp File third_party/WebKit/Source/core/workers/WorkerThread.cpp (right): https://codereview.chromium.org/2041753002/diff/160001/third_party/WebKit/Source/core/workers/WorkerThread.cpp#newcode244 third_party/WebKit/Source/core/workers/WorkerThread.cpp:244: if (isolate()) On 2016/06/09 08:57:42, kinuko wrote: ...
4 years, 6 months ago (2016-06-09 09:33:36 UTC) #28
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2041753002/180001
4 years, 6 months ago (2016-06-09 09:34:05 UTC) #31
commit-bot: I haz the power
Committed patchset #5 (id:180001)
4 years, 6 months ago (2016-06-09 11:03:52 UTC) #33
commit-bot: I haz the power
4 years, 6 months ago (2016-06-09 11:04:46 UTC) #35
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/48b51b66bbd7193a56102c49dc2b6ebea67274dc
Cr-Commit-Position: refs/heads/master@{#398837}

Powered by Google App Engine
This is Rietveld 408576698