exceptions.
It turned out that the stack overflow fix from before had disabled
message storing in another test. Previously, stack overflows would
actually cause a message object to start being created but cause
another exception which would not be reported and that's what stopped
the infinite regress. This change resores that behavior.
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@259
ce2b1a6d-e550-0410-aec6-
3dcde31c8c00
*/
void SetVerbose(bool value);
+ /**
+ * Set whether or not this TryCatch should capture a Message object
+ * which holds source information about where the exception
+ * occurred. True by default.
+ */
+ void SetCaptureMessage(bool value);
+
public:
TryCatch* next_;
void* exception_;
void* message_;
bool is_verbose_;
+ bool capture_message_;
};
: next_(i::Top::try_catch_handler()),
exception_(i::Heap::the_hole_value()),
message_(i::Smi::FromInt(0)),
- is_verbose_(false) {
+ is_verbose_(false),
+ capture_message_(true) {
i::Top::RegisterTryCatchHandler(this);
}
}
+void v8::TryCatch::SetCaptureMessage(bool value) {
+ capture_message_ = value;
+}
+
+
// --- M e s s a g e ---
Object*** args,
bool* caught_exception) {
// Enter a try-block while executing the JavaScript code. To avoid
- // duplicate error printing it must be non-verbose.
+ // duplicate error printing it must be non-verbose. Also, to avoid
+ // creating message objects during stack overflow we shouldn't
+ // capture messages.
v8::TryCatch catcher;
catcher.SetVerbose(false);
+ catcher.SetCaptureMessage(false);
Handle<Object> result = Invoke(false, func, receiver, argc, args,
caught_exception);
Handle<Object> message_obj;
MessageLocation potential_computed_location;
- if (report_exception) {
+ bool try_catch_needs_message =
+ is_caught_externally && thread_local_.try_catch_handler_->capture_message_;
+ if (report_exception || try_catch_needs_message) {
if (location == NULL) {
// If no location was specified we use a computed one instead
ComputeLocation(&potential_computed_location);
}
+THREADED_TEST(CatchStackOverflow) {
+ v8::HandleScope scope;
+ LocalContext context;
+ v8::TryCatch try_catch;
+ v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(
+ "function f() {"
+ " return f();"
+ "}"
+ ""
+ "f();"));
+ v8::Handle<v8::Value> result = script->Run();
+ CHECK(result.IsEmpty());
+}
+
+
THREADED_TEST(TryCatchSourceInfo) {
v8::HandleScope scope;
LocalContext context;