Reviewers: jarin,

Description:
d8 workers: fix race on quit() with context_mutex_

When quit() is called, d8 shell exits without cleanup. If a worker is running,
it might be holding the context_mutex_, which if destroyed will DCHECK.

BUG=4279
[email protected]
LOG=n

Please review this at https://codereview.chromium.org/1231473002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+8, -8 lines):
  M src/d8.cc
  A + test/mjsunit/regress/regress-4279.js


Index: src/d8.cc
diff --git a/src/d8.cc b/src/d8.cc
index 7db6f3ed9e442081528e05140bd25b8911e26cb6..854727125fda5e0147e979a863513e7917d20dd7 100644
--- a/src/d8.cc
+++ b/src/d8.cc
@@ -810,6 +810,9 @@ void Shell::WorkerTerminate(const v8::FunctionCallbackInfo<v8::Value>& args) {

 void Shell::Quit(const v8::FunctionCallbackInfo<v8::Value>& args) {
   int exit_code = args[0]->Int32Value();
+#ifndef V8_SHARED
+  CleanupWorkers();
+#endif  // !V8_SHARED
   OnExit(args.GetIsolate());
   exit(exit_code);
 }
Index: test/mjsunit/regress/regress-4279.js
diff --git a/test/mjsunit/regress/regress-crbug-501711.js b/test/mjsunit/regress/regress-4279.js
similarity index 64%
copy from test/mjsunit/regress/regress-crbug-501711.js
copy to test/mjsunit/regress/regress-4279.js
index f8eda6e8d8e26f41b79e05af891b0f5446b5cd37..64ef967d8941cf384125b7bfbe2a04dd88fddd59 100644
--- a/test/mjsunit/regress/regress-crbug-501711.js
+++ b/test/mjsunit/regress/regress-4279.js
@@ -2,13 +2,10 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.

-// Flags: --stack-size=100
-
-function f() {
+if (this.Worker && this.quit) {
   try {
-    f();
-  } catch(e) {
-    Realm.create();
-  }
+      new Function(new Worker("55"));
+  } catch(err) {}
+
+  quit();
 }
-f();


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to