Reviewers: Toon Verwaest,

Description:
Do not expose termination exceptions to the API.

R=verwa...@chromium.org
BUG=403509

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

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+21, -0 lines):
  M src/api.cc
  M src/debug.cc
  M test/cctest/test-thread-termination.cc


Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 667f9afcbceb3471ea1e77c17673002910b1a096..6cc4b149acda4e5764e024054847dbd37ad60337 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -6830,6 +6830,7 @@ Local<Value> Exception::RangeError(v8::Handle<v8::String> raw_message) {
     i::HandleScope scope(isolate);
     i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
i::Handle<i::Object> result = isolate->factory()->NewRangeError(message);
+    if (!result->IsJSObject()) return Local<Value>();
     error = *result;
   }
   i::Handle<i::Object> result(error, isolate);
@@ -6848,6 +6849,7 @@ Local<Value> Exception::ReferenceError(v8::Handle<v8::String> raw_message) {
     i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
     i::Handle<i::Object> result =
         isolate->factory()->NewReferenceError(message);
+    if (!result->IsJSObject()) return Local<Value>();
     error = *result;
   }
   i::Handle<i::Object> result(error, isolate);
@@ -6865,6 +6867,7 @@ Local<Value> Exception::SyntaxError(v8::Handle<v8::String> raw_message) {
     i::HandleScope scope(isolate);
     i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
i::Handle<i::Object> result = isolate->factory()->NewSyntaxError(message);
+    if (!result->IsJSObject()) return Local<Value>();
     error = *result;
   }
   i::Handle<i::Object> result(error, isolate);
@@ -6882,6 +6885,7 @@ Local<Value> Exception::TypeError(v8::Handle<v8::String> raw_message) {
     i::HandleScope scope(isolate);
     i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
i::Handle<i::Object> result = isolate->factory()->NewTypeError(message);
+    if (!result->IsJSObject()) return Local<Value>();
     error = *result;
   }
   i::Handle<i::Object> result(error, isolate);
@@ -6899,6 +6903,7 @@ Local<Value> Exception::Error(v8::Handle<v8::String> raw_message) {
     i::HandleScope scope(isolate);
     i::Handle<i::String> message = Utils::OpenHandle(*raw_message);
     i::Handle<i::Object> result = isolate->factory()->NewError(message);
+    if (!result->IsJSObject()) return Local<Value>();
     error = *result;
   }
   i::Handle<i::Object> result(error, isolate);
Index: src/debug.cc
diff --git a/src/debug.cc b/src/debug.cc
index f4ab1159aae9a40a62736668d53b364c569a4ddd..c902cd6f0ef25fbfec4f78eee9edf00652ce8b36 100644
--- a/src/debug.cc
+++ b/src/debug.cc
@@ -2889,6 +2889,11 @@ void Debug::NotifyMessageHandler(v8::DebugEvent event,
           isolate_, is_running, cmd_processor, 1, is_running_args);
       running = maybe_result.ToHandleChecked()->IsTrue();
     } else {
+      if (exception.is_identical_to(
+              isolate_->factory()->termination_exception())) {
+        command_queue_.Clear();
+        break;
+      }
       answer = Handle<String>::cast(
           Execution::ToString(isolate_, exception).ToHandleChecked());
     }
Index: test/cctest/test-thread-termination.cc
diff --git a/test/cctest/test-thread-termination.cc b/test/cctest/test-thread-termination.cc index a5ed7ab9bfe9231a689958ddde46b55af170375f..f77a6983697e1717d243f55ab0c88bc0db9c5ae8 100644
--- a/test/cctest/test-thread-termination.cc
+++ b/test/cctest/test-thread-termination.cc
@@ -459,3 +459,14 @@ TEST(PostponeTerminateException) {
   CHECK(try_catch.HasTerminated());
   CHECK_EQ(2, callback_counter);
 }
+
+
+TEST(ErrorObjectAfterTermination) {
+  v8::Isolate* isolate = CcTest::isolate();
+  v8::HandleScope scope(isolate);
+  v8::Handle<v8::Context> context = v8::Context::New(CcTest::isolate());
+  v8::Context::Scope context_scope(context);
+  v8::V8::TerminateExecution(isolate);
+  v8::Local<v8::Value> error = v8::Exception::Error(v8_str("error"));
+  CHECK(error.IsEmpty());
+}


--
--
v8-dev mailing list
v8-dev@googlegroups.com
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 v8-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to