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

Issue 1555643002: Thread fixes for shutdown. (Closed)

Created:
4 years, 11 months ago by zra
Modified:
4 years, 11 months ago
CC:
reviews_dartlang.org, vm-dev_dartlang.org
Base URL:
git@github.com:dart-lang/sdk.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

Thread fixes for shutdown. - Don't disable thread creation until isolates have shutdown. - A thread-pool thread may try to start up after thread creation has been disabled. We must reap the Worker objects for these threads. - A thread may try to start up after OSThread::thread_list_lock_ has been destroyed. Detect this. R=asiva@google.com Committed: https://github.com/dart-lang/sdk/commit/a6818de006a5bbd364a392ef44fa1c256e2da9da

Patch Set 1 #

Patch Set 2 : #

Total comments: 6

Patch Set 3 : Address comments #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+28 lines, -12 lines) Patch
M runtime/vm/dart.cc View 3 chunks +8 lines, -4 lines 0 comments Download
M runtime/vm/os_thread.cc View 1 chunk +10 lines, -6 lines 2 comments Download
M runtime/vm/thread_pool.cc View 1 2 3 chunks +10 lines, -2 lines 0 comments Download

Messages

Total messages: 11 (3 generated)
zra
4 years, 11 months ago (2015-12-30 16:40:09 UTC) #2
siva
LGTM with one comment. https://codereview.chromium.org/1555643002/diff/20001/runtime/vm/thread_pool.cc File runtime/vm/thread_pool.cc (right): https://codereview.chromium.org/1555643002/diff/20001/runtime/vm/thread_pool.cc#newcode120 runtime/vm/thread_pool.cc:120: current->Shutdown(); Why is it necessary ...
4 years, 11 months ago (2015-12-30 20:51:02 UTC) #3
zra
https://codereview.chromium.org/1555643002/diff/20001/runtime/vm/thread_pool.cc File runtime/vm/thread_pool.cc (right): https://codereview.chromium.org/1555643002/diff/20001/runtime/vm/thread_pool.cc#newcode120 runtime/vm/thread_pool.cc:120: current->Shutdown(); On 2015/12/30 20:51:02, siva wrote: > Why is ...
4 years, 11 months ago (2015-12-30 22:36:28 UTC) #4
zra
Committed patchset #3 (id:40001) manually as a6818de006a5bbd364a392ef44fa1c256e2da9da (presubmit successful).
4 years, 11 months ago (2015-12-30 23:01:36 UTC) #6
Vyacheslav Egorov (Google)
driveby https://codereview.chromium.org/1555643002/diff/40001/runtime/vm/os_thread.cc File runtime/vm/os_thread.cc (right): https://codereview.chromium.org/1555643002/diff/40001/runtime/vm/os_thread.cc#newcode43 runtime/vm/os_thread.cc:43: MutexLocker ml(thread_list_lock_); Code like this is a red-flag ...
4 years, 11 months ago (2016-01-02 16:41:30 UTC) #8
siva
On 2016/01/02 16:41:30, Vyacheslav Egorov (Google) wrote: > driveby > > https://codereview.chromium.org/1555643002/diff/40001/runtime/vm/os_thread.cc > File runtime/vm/os_thread.cc ...
4 years, 11 months ago (2016-01-03 03:26:49 UTC) #9
Florian Schneider
On 2016/01/03 03:26:49, siva wrote: > On 2016/01/02 16:41:30, Vyacheslav Egorov (Google) wrote: > > ...
4 years, 11 months ago (2016-01-04 08:38:42 UTC) #10
zra
4 years, 11 months ago (2016-01-04 17:19:10 UTC) #11
Message was sent while issue was closed.
I think Siva is right and this lock will be difficult to delete. I'll remove the
deletion, and add some comments explaining the situation.

https://codereview.chromium.org/1555643002/diff/40001/runtime/vm/os_thread.cc
File runtime/vm/os_thread.cc (right):

https://codereview.chromium.org/1555643002/diff/40001/runtime/vm/os_thread.cc...
runtime/vm/os_thread.cc:43: MutexLocker ml(thread_list_lock_);
On 2016/01/02 16:41:30, Vyacheslav Egorov (Google) wrote:
> Code like this is a red-flag in multithreaded environment for two reasons:
> 
> 1. You fetch a value twice and expect that it does not change in between but
> there is no lock spanning these two accesses. Depending on how compiler
compiles
> this code you might end up with a race.
> 
> 2. Manual managed lifetime of the mutex is bad. Mutex might be freed by
another
> thread right when we try to acquire it, so even rewriting the code like this:
> 
> Mutex* lock = thread_list_lock_;
> if (lock == NULL) return NULL;
> MutexLocker ml(lock);
> 
> guarantees *nothing*. 
> 
> Global locks should usually have static lifetime to guarantee correctness. 

Acknowledged.

Powered by Google App Engine
This is Rietveld 408576698