Allow GetScriptNameOrSourceURL to be called with exception pending.
authoryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 14 Apr 2014 08:27:00 +0000 (08:27 +0000)
committeryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 14 Apr 2014 08:27:00 +0000 (08:27 +0000)
R=jarin@chromium.org, ishell@chromium.org

Review URL: https://codereview.chromium.org/235943006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@20705 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/handles.cc
test/cctest/test-api.cc

index af1ffab..f70848f 100644 (file)
@@ -399,10 +399,11 @@ Handle<Object> GetScriptNameOrSourceURL(Handle<Script> script) {
   ASSERT(property->IsJSFunction());
   Handle<JSFunction> method = Handle<JSFunction>::cast(property);
   Handle<Object> result;
-  ASSIGN_RETURN_ON_EXCEPTION_VALUE(
-      isolate, result,
-      Execution::TryCall(method, script_wrapper, 0, NULL),
-      isolate->factory()->undefined_value());
+  // Do not check against pending exception, since this function may be called
+  // when an exception has already been pending.
+  if (!Execution::TryCall(method, script_wrapper, 0, NULL).ToHandle(&result)) {
+    return isolate->factory()->undefined_value();
+  }
   return result;
 }
 
index 14aa700..78ecc36 100644 (file)
@@ -22428,3 +22428,16 @@ TEST(Regress354123) {
   CompileRun("Object.getPrototypeOf(friend);");
   CHECK_EQ(2, named_access_count);
 }
+
+
+TEST(CaptureStackTraceForStackOverflow) {
+  v8::internal::FLAG_stack_size = 150;
+  LocalContext current;
+  v8::Isolate* isolate = current->GetIsolate();
+  v8::HandleScope scope(isolate);
+  V8::SetCaptureStackTraceForUncaughtExceptions(
+      true, 10, v8::StackTrace::kDetailed);
+  v8::TryCatch try_catch;
+  CompileRun("(function f(x) { f(x+1); })(0)");
+  CHECK(try_catch.HasCaught());
+}