From 8655dec00e63f309ffbbde29d40b0e6a232aeeff Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 23 Jan 2014 20:30:44 +0800 Subject: [PATCH] Crash when there is fatal error in V8. --- common/api/atom_bindings.cc | 8 ++++++++ vendor/node | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/common/api/atom_bindings.cc b/common/api/atom_bindings.cc index 8dc3b85a45a1..3e58d8fe72fa 100644 --- a/common/api/atom_bindings.cc +++ b/common/api/atom_bindings.cc @@ -53,6 +53,13 @@ void UvOnCallback(uv_async_t* handle, int status) { g_v8_callback->NewHandle()->Call(global, 0, NULL); } +// Called when there is a fatal error in V8, we just crash the process here so +// we can get the stack trace. +void FatalErrorCallback(const char* location, const char* message) { + LOG(ERROR) << "Fatal error in V8: " << location << " " << message; + static_cast(NULL)->crash = true; +} + v8::Handle DumpStackFrame(v8::Handle stack_frame) { v8::Local result = v8::Object::New(); result->Set(ToV8Value("line"), ToV8Value(stack_frame->GetLineNumber())); @@ -76,6 +83,7 @@ node::node_module_struct* GetBuiltinModule(const char *name, bool is_browser); AtomBindings::AtomBindings() { uv_async_init(uv_default_loop(), &g_next_tick_uv_handle, UvCallNextTick); uv_async_init(uv_default_loop(), &g_callback_uv_handle, UvOnCallback); + v8::V8::SetFatalErrorHandler(FatalErrorCallback); } AtomBindings::~AtomBindings() { diff --git a/vendor/node b/vendor/node index 7fa644854f91..80c5e17c09fd 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 7fa644854f91c8dd23d8cec21be1310f0b69d813 +Subproject commit 80c5e17c09fdf2fc0b74353b285bb33a6ecf5e62