Added option for TryCatches to not capture the message object on

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
parent dfe27209
......@@ -1993,11 +1993,19 @@ class EXPORT TryCatch {
*/
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_;
};
......
......@@ -1082,7 +1082,8 @@ v8::TryCatch::TryCatch()
: 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);
}
......@@ -1129,6 +1130,11 @@ void v8::TryCatch::SetVerbose(bool value) {
}
void v8::TryCatch::SetCaptureMessage(bool value) {
capture_message_ = value;
}
// --- M e s s a g e ---
......
......@@ -130,9 +130,12 @@ Handle<Object> Execution::TryCall(Handle<JSFunction> func,
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);
......
......@@ -770,7 +770,9 @@ void Top::DoThrow(Object* 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);
......
......@@ -4845,6 +4845,21 @@ THREADED_TEST(Regress54) {
}
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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment