Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1391)

Side by Side Diff: src/top.cc

Issue 194070: Fix crash during error reporting during bootstrapping. (Closed)
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/factory.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 Handle<Script> casted_script(Script::cast(script)); 683 Handle<Script> casted_script(Script::cast(script));
684 *target = MessageLocation(casted_script, pos, pos + 1); 684 *target = MessageLocation(casted_script, pos, pos + 1);
685 } 685 }
686 } 686 }
687 } 687 }
688 688
689 689
690 void Top::ReportUncaughtException(Handle<Object> exception, 690 void Top::ReportUncaughtException(Handle<Object> exception,
691 MessageLocation* location, 691 MessageLocation* location,
692 Handle<String> stack_trace) { 692 Handle<String> stack_trace) {
693 Handle<Object> message = 693 Handle<Object> message;
694 MessageHandler::MakeMessageObject("uncaught_exception", 694 if (!Bootstrapper::IsActive()) {
695 location, 695 // It's not safe to try to make message objects while the bootstrapper
696 HandleVector<Object>(&exception, 1), 696 // is active since the infrastructure may not have been properly
697 stack_trace); 697 // initialized.
698 698 message =
699 MessageHandler::MakeMessageObject("uncaught_exception",
700 location,
701 HandleVector<Object>(&exception, 1),
702 stack_trace);
703 }
699 // Report the uncaught exception. 704 // Report the uncaught exception.
700 MessageHandler::ReportMessage(location, message); 705 MessageHandler::ReportMessage(location, message);
701 } 706 }
702 707
703 708
704 bool Top::ShouldReturnException(bool* is_caught_externally, 709 bool Top::ShouldReturnException(bool* is_caught_externally,
705 bool catchable_by_javascript) { 710 bool catchable_by_javascript) {
706 // Find the top-most try-catch handler. 711 // Find the top-most try-catch handler.
707 StackHandler* handler = 712 StackHandler* handler =
708 StackHandler::FromAddress(Top::handler(Top::GetCurrentThread())); 713 StackHandler::FromAddress(Top::handler(Top::GetCurrentThread()));
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 MessageLocation potential_computed_location; 767 MessageLocation potential_computed_location;
763 bool try_catch_needs_message = 768 bool try_catch_needs_message =
764 is_caught_externally && 769 is_caught_externally &&
765 thread_local_.try_catch_handler_->capture_message_; 770 thread_local_.try_catch_handler_->capture_message_;
766 if (report_exception || try_catch_needs_message) { 771 if (report_exception || try_catch_needs_message) {
767 if (location == NULL) { 772 if (location == NULL) {
768 // If no location was specified we use a computed one instead 773 // If no location was specified we use a computed one instead
769 ComputeLocation(&potential_computed_location); 774 ComputeLocation(&potential_computed_location);
770 location = &potential_computed_location; 775 location = &potential_computed_location;
771 } 776 }
772 Handle<String> stack_trace; 777 if (!Bootstrapper::IsActive()) {
773 if (FLAG_trace_exception) stack_trace = StackTrace(); 778 // It's not safe to try to make message objects or collect stack
774 message_obj = MessageHandler::MakeMessageObject("uncaught_exception", 779 // traces while the bootstrapper is active since the infrastructure
775 location, HandleVector<Object>(&exception_handle, 1), stack_trace); 780 // may not have been properly initialized.
781 Handle<String> stack_trace;
782 if (FLAG_trace_exception) stack_trace = StackTrace();
783 message_obj = MessageHandler::MakeMessageObject("uncaught_exception",
784 location, HandleVector<Object>(&exception_handle, 1), stack_trace);
785 }
776 } 786 }
777 787
778 // Save the message for reporting if the the exception remains uncaught. 788 // Save the message for reporting if the the exception remains uncaught.
779 thread_local_.has_pending_message_ = report_exception; 789 thread_local_.has_pending_message_ = report_exception;
780 thread_local_.pending_message_ = message; 790 thread_local_.pending_message_ = message;
781 if (!message_obj.is_null()) { 791 if (!message_obj.is_null()) {
782 thread_local_.pending_message_obj_ = *message_obj; 792 thread_local_.pending_message_obj_ = *message_obj;
783 if (location != NULL) { 793 if (location != NULL) {
784 thread_local_.pending_message_script_ = *location->script(); 794 thread_local_.pending_message_script_ = *location->script();
785 thread_local_.pending_message_start_pos_ = location->start_pos(); 795 thread_local_.pending_message_start_pos_ = location->start_pos();
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 Top::break_access_->Lock(); 973 Top::break_access_->Lock();
964 } 974 }
965 975
966 976
967 ExecutionAccess::~ExecutionAccess() { 977 ExecutionAccess::~ExecutionAccess() {
968 Top::break_access_->Unlock(); 978 Top::break_access_->Unlock();
969 } 979 }
970 980
971 981
972 } } // namespace v8::internal 982 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/factory.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698