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

Side by Side Diff: runtime/vm/dart.cc

Issue 1557033002: Fixes for OSThread creation shutdown race. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address comments Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/os_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/dart.h" 5 #include "vm/dart.h"
6 6
7 #include "vm/code_observers.h" 7 #include "vm/code_observers.h"
8 #include "vm/cpu.h" 8 #include "vm/cpu.h"
9 #include "vm/dart_api_state.h" 9 #include "vm/dart_api_state.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 // Send the OOB Kill message to all remaining application isolates. 241 // Send the OOB Kill message to all remaining application isolates.
242 Isolate::KillAllIsolates(Isolate::kInternalKillMsg); 242 Isolate::KillAllIsolates(Isolate::kInternalKillMsg);
243 243
244 // Shutdown the service isolate. 244 // Shutdown the service isolate.
245 ServiceIsolate::Shutdown(); 245 ServiceIsolate::Shutdown();
246 246
247 // Wait for all application isolates and the service isolate to shutdown 247 // Wait for all application isolates and the service isolate to shutdown
248 // before shutting down the thread pool. 248 // before shutting down the thread pool.
249 WaitForIsolateShutdown(); 249 WaitForIsolateShutdown();
250 250
251 // Disable creation of any new OSThread structures which means no more new
252 // threads can do an EnterIsolate. This must come after isolate shutdown
253 // because new threads may need to be spawned to shutdown the isolates.
254 OSThread::DisableOSThreadCreation();
255
256 // Shutdown the thread pool. On return, all thread pool threads have exited. 251 // Shutdown the thread pool. On return, all thread pool threads have exited.
257 delete thread_pool_; 252 delete thread_pool_;
258 thread_pool_ = NULL; 253 thread_pool_ = NULL;
259 254
255 // Disable creation of any new OSThread structures which means no more new
256 // threads can do an EnterIsolate. This must come after isolate shutdown
257 // because new threads may need to be spawned to shutdown the isolates.
258 // This must come after deletion of the thread pool to avoid a race in which
259 // a thread spawned by the thread pool does not exit through the thread
260 // pool, messing up its bookkeeping.
261 OSThread::DisableOSThreadCreation();
262
260 // Set the VM isolate as current isolate. 263 // Set the VM isolate as current isolate.
261 bool result = Thread::EnterIsolate(vm_isolate_); 264 bool result = Thread::EnterIsolate(vm_isolate_);
262 ASSERT(result); 265 ASSERT(result);
263 266
264 ShutdownIsolate(); 267 ShutdownIsolate();
265 vm_isolate_ = NULL; 268 vm_isolate_ = NULL;
266 ASSERT(Isolate::IsolateListLength() == 0); 269 ASSERT(Isolate::IsolateListLength() == 0);
267 270
268 TargetCPUFeatures::Cleanup(); 271 TargetCPUFeatures::Cleanup();
269 StoreBuffer::ShutDown(); 272 StoreBuffer::ShutDown();
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 return predefined_handles_->handles_.IsValidScopedHandle(address); 455 return predefined_handles_->handles_.IsValidScopedHandle(address);
453 } 456 }
454 457
455 458
456 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) { 459 bool Dart::IsReadOnlyApiHandle(Dart_Handle handle) {
457 ASSERT(predefined_handles_ != NULL); 460 ASSERT(predefined_handles_ != NULL);
458 return predefined_handles_->api_handles_.IsValidHandle(handle); 461 return predefined_handles_->api_handles_.IsValidHandle(handle);
459 } 462 }
460 463
461 } // namespace dart 464 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/os_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698