Revision: 2867 Author: [email protected] Date: Wed Sep 9 23:52:46 2009 Log: Fix crash during error reporting during bootstrapping. Instead of crashing or reporting a fatal v8 error if an error occurs during context initialization we now survive and return an empty handle.
Review URL: http://codereview.chromium.org/194070 http://code.google.com/p/v8/source/detail?r=2867 Modified: /branches/bleeding_edge/src/api.cc /branches/bleeding_edge/src/factory.cc /branches/bleeding_edge/src/top.cc ======================================= --- /branches/bleeding_edge/src/api.cc Fri Sep 4 00:34:25 2009 +++ /branches/bleeding_edge/src/api.cc Wed Sep 9 23:52:46 2009 @@ -2672,9 +2672,7 @@ } // Leave V8. - if (!ApiCheck(!env.is_null(), - "v8::Context::New()", - "Could not initialize environment")) + if (env.is_null()) return Persistent<Context>(); return Persistent<Context>(Utils::ToLocal(env)); } ======================================= --- /branches/bleeding_edge/src/factory.cc Tue Aug 18 00:14:02 2009 +++ /branches/bleeding_edge/src/factory.cc Wed Sep 9 23:52:46 2009 @@ -401,10 +401,12 @@ const char* type, Handle<JSArray> args) { Handle<String> make_str = Factory::LookupAsciiSymbol(maker); - Handle<JSFunction> fun = - Handle<JSFunction>( - JSFunction::cast( - Top::builtins()->GetProperty(*make_str))); + Handle<Object> fun_obj(Top::builtins()->GetProperty(*make_str)); + // If the builtins haven't been properly configured yet this error + // constructor may not have been defined. Bail out. + if (!fun_obj->IsJSFunction()) + return Factory::undefined_value(); + Handle<JSFunction> fun = Handle<JSFunction>::cast(fun_obj); Handle<Object> type_obj = Factory::LookupAsciiSymbol(type); Object** argv[2] = { type_obj.location(), Handle<Object>::cast(args).location() }; ======================================= --- /branches/bleeding_edge/src/top.cc Tue Sep 1 06:55:45 2009 +++ /branches/bleeding_edge/src/top.cc Wed Sep 9 23:52:46 2009 @@ -690,12 +690,17 @@ void Top::ReportUncaughtException(Handle<Object> exception, MessageLocation* location, Handle<String> stack_trace) { - Handle<Object> message = - MessageHandler::MakeMessageObject("uncaught_exception", - location, - HandleVector<Object>(&exception, 1), - stack_trace); - + Handle<Object> message; + if (!Bootstrapper::IsActive()) { + // It's not safe to try to make message objects while the bootstrapper + // is active since the infrastructure may not have been properly + // initialized. + message = + MessageHandler::MakeMessageObject("uncaught_exception", + location, + HandleVector<Object>(&exception, 1), + stack_trace); + } // Report the uncaught exception. MessageHandler::ReportMessage(location, message); } @@ -769,10 +774,15 @@ ComputeLocation(&potential_computed_location); location = &potential_computed_location; } - Handle<String> stack_trace; - if (FLAG_trace_exception) stack_trace = StackTrace(); - message_obj = MessageHandler::MakeMessageObject("uncaught_exception", - location, HandleVector<Object>(&exception_handle, 1), stack_trace); + if (!Bootstrapper::IsActive()) { + // It's not safe to try to make message objects or collect stack + // traces while the bootstrapper is active since the infrastructure + // may not have been properly initialized. + Handle<String> stack_trace; + if (FLAG_trace_exception) stack_trace = StackTrace(); + message_obj = MessageHandler::MakeMessageObject("uncaught_exception", + location, HandleVector<Object>(&exception_handle, 1), stack_trace); + } } // Save the message for reporting if the the exception remains uncaught. --~--~---------~--~----~------------~-------~--~----~ v8-dev mailing list [email protected] http://groups.google.com/group/v8-dev -~----------~----~----~----~------~----~------~--~---
