Reviewers: Mads Ager,

Description:
Report stack overflow exceptions to V8 message listeners

Stack overflow exceptions like other JavaScript exceptions should be reported to
listeners added via V8::AddMessageListener.

Corresponding Chromium issue:
http://code.google.com/p/chromium/issues/detail?id=63704

Please review this at http://codereview.chromium.org/6816021/

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

Affected files:
  M     src/top.cc
  M     test/cctest/test-api.cc


Index: src/top.cc
===================================================================
--- src/top.cc  (revision 7547)
+++ src/top.cc  (working copy)
@@ -828,7 +828,8 @@
       thread_local_top()->has_pending_message_ = false;
       if (thread_local_top()->pending_message_ != NULL) {
MessageHandler::ReportMessage(thread_local_top()->pending_message_);
-      } else if (!thread_local_top()->pending_message_obj_->IsTheHole()) {
+      }
+      if (!thread_local_top()->pending_message_obj_->IsTheHole()) {
Handle<Object> message_obj(thread_local_top()->pending_message_obj_);
         if (thread_local_top()->pending_message_script_ != NULL) {
Handle<Script> script(thread_local_top()->pending_message_script_);
Index: test/cctest/test-api.cc
===================================================================
--- test/cctest/test-api.cc     (revision 7547)
+++ test/cctest/test-api.cc     (working copy)
@@ -2655,6 +2655,21 @@
 }


+TEST(APIStackOverflowAndVerboseTryCatch) {
+  message_received = false;
+  v8::HandleScope scope;
+  v8::V8::AddMessageListener(receive_message);
+  LocalContext context;
+  v8::TryCatch try_catch;
+  try_catch.SetVerbose(true);
+  Local<Value> result = CompileRun("function foo() { foo(); } foo();");
+  CHECK(try_catch.HasCaught());
+  CHECK(result.IsEmpty());
+  CHECK(message_received);
+  v8::V8::RemoveMessageListeners(receive_message);
+}
+
+
 THREADED_TEST(ExternalScriptException) {
   v8::HandleScope scope;
   Local<ObjectTemplate> templ = ObjectTemplate::New();


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to