Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

OS-1937 add support for abort_on_uncaught_exception in platform node.

  • Loading branch information...
commit 4e9fd771fae490b5c58fba8feb8ca08e8753689a 1 parent be56b45
@joshwilsdon joshwilsdon authored
Showing with 37 additions and 0 deletions.
  1. +37 −0 node.js/Patches/abort_on_uncaught_exception.patch
View
37 node.js/Patches/abort_on_uncaught_exception.patch
@@ -0,0 +1,37 @@
+diff --git node-v0.8.20-32.orig/deps/v8/src/flag-definitions.h node-v0.8.20-32/deps/v8/src/flag-definitions.h
+index 9fd23f9..8809b35 100644
+--- node-v0.8.20-32.orig/deps/v8/src/flag-definitions.h
++++ node-v0.8.20-32/deps/v8/src/flag-definitions.h
+@@ -489,6 +489,8 @@ struct JSArguments {
+ "Stack alingment in bytes in simulator (4 or 8, 8 is default)")
+
+ // isolate.cc
++DEFINE_bool(abort_on_uncaught_exception, false,
++ "abort program (dump core) when an uncaught exception is thrown")
+ DEFINE_bool(trace_exception, false,
+ "print stack trace when throwing exceptions")
+ DEFINE_bool(preallocate_message_memory, false,
+diff --git node-v0.8.20-32.orig/deps/v8/src/isolate.cc node-v0.8.20-32/deps/v8/src/isolate.cc
+index 61d2b2d..8ee5204 100644
+--- node-v0.8.20-32.orig/deps/v8/src/isolate.cc
++++ node-v0.8.20-32/deps/v8/src/isolate.cc
+@@ -1266,6 +1266,19 @@ void Isolate::DoThrow(Object* exception, MessageLocation* location) {
+ thread_local_top()->pending_message_start_pos_ = location->start_pos();
+ thread_local_top()->pending_message_end_pos_ = location->end_pos();
+ }
++
++ // If the abort-on-uncaught-exception flag is specified, abort on any
++ // exception not caught by JavaScript, even when an external handler is
++ // present. This flag is intended for use by JavaScript developers, so
++ // print a user-friendly stack trace (not an internal one).
++ if (FLAG_abort_on_uncaught_exception &&
++ (report_exception || can_be_caught_externally)) {
++ fprintf(stderr, "UNCAUGHT EXCEPTION (%p): dumping core\n\n",
++ exception);
++ PrintCurrentStackTrace(stderr);
++ OS::Abort();
++ }
++
+ } else if (location != NULL && !location->script().is_null()) {
+ // We are bootstrapping and caught an error where the location is set
+ // and we have a script for the location.
Please sign in to comment.
Something went wrong with that request. Please try again.