Index: test/cctest/test-api.cc |
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc |
index b3c8515fc0d8f720e2750c45f5075c31a8206721..514a22fcf31fdf3fb93c3f147315535326d4ade6 100644 |
--- a/test/cctest/test-api.cc |
+++ b/test/cctest/test-api.cc |
@@ -8662,3 +8662,29 @@ THREADED_TEST(QuietSignalingNaNs) { |
} |
} |
} |
+ |
+ |
+static v8::Handle<Value> SpaghettiIncident(const v8::Arguments& args) { |
+ v8::HandleScope scope; |
+ v8::TryCatch tc; |
+ v8::Handle<v8::String> str = args[0]->ToString(); |
+ if (tc.HasCaught()) |
+ return tc.ReThrow(); |
+ return v8::Undefined(); |
+} |
+ |
+ |
+// Test that a stack overflow can be propagated down through a spaghetti |
+// stack using ReThrow. |
+THREADED_TEST(SpaghettiStackOverflow) { |
+ v8::HandleScope scope; |
+ LocalContext context; |
+ context->Global()->Set( |
+ v8::String::New("s"), |
+ v8::FunctionTemplate::New(SpaghettiIncident)->GetFunction()); |
+ v8::TryCatch try_catch; |
+ CompileRun("var o = {toString: function () {return s(o);}}; s(o);"); |
+ CHECK(try_catch.HasCaught()); |
+ v8::String::Utf8Value value(try_catch.Exception()); |
+ CHECK_NE(0, strstr(*value, "RangeError")); |
+} |