From 54caadc6ef5e27d9967c18ea9ca4996cdd5a558d Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 24 Dec 2019 14:24:01 +0100 Subject: [PATCH] src: enable stack trace printing for V8 check failures MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Example output: $ ./node --expose-gc test/addons/buffer-free-callback/test.js # # Fatal error in , line 0 # Check failed: result.second. # # # #FailureMessage Object: 0x7ffebd956860 1: 0x56290a45b105 [./node] 2: 0x56290b305b77 V8_Fatal(char const*, ...) [./node] 3: 0x56290a82702d v8::internal::GlobalBackingStoreRegistry::Register(std::shared_ptr) [./node] 4: 0x56290a59a1de v8::ArrayBuffer::GetBackingStore() [./node] 5: 0x56290a3cb63f node::Buffer::New(node::Environment*, char*, unsigned long, void (*)(char*, void*), void*) [./node] 6: 0x56290a3cbcdc node::Buffer::New(v8::Isolate*, char*, unsigned long, void (*)(char*, void*), void*) [./node] 7: 0x7fdeabdfdf89 Alloc(v8::FunctionCallbackInfo const&) [/home/xxxx/src/node/master/test/addons/buffer-free-callback/build/Release/binding.node] 8: 0x56290a5ca077 [./node] 9: 0x56290a5cbf97 v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*) [./node] 10: 0x56290ad99539 [./node] Illegal instruction (core dumped) PR-URL: https://github.com/nodejs/node/pull/31079 Reviewed-By: Gireesh Punathil Reviewed-By: Colin Ihrig Reviewed-By: Richard Lau Reviewed-By: Rich Trott Reviewed-By: Michaƫl Zasso Reviewed-By: Ben Noordhuis Reviewed-By: Gus Caplan Reviewed-By: James M Snell --- src/node_platform.cc | 8 ++++++++ src/node_platform.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/src/node_platform.cc b/src/node_platform.cc index 5a98b04f535bb0..a3e39df6ccce96 100644 --- a/src/node_platform.cc +++ b/src/node_platform.cc @@ -485,6 +485,14 @@ TracingController* NodePlatform::GetTracingController() { return tracing_controller_; } +Platform::StackTracePrinter NodePlatform::GetStackTracePrinter() { + return []() { + fprintf(stderr, "\n"); + DumpBacktrace(stderr); + fflush(stderr); + }; +} + template TaskQueue::TaskQueue() : lock_(), tasks_available_(), tasks_drained_(), diff --git a/src/node_platform.h b/src/node_platform.h index 24f7b337bb8fd7..bebd61b0c22644 100644 --- a/src/node_platform.h +++ b/src/node_platform.h @@ -169,6 +169,8 @@ class NodePlatform : public MultiIsolatePlatform { std::shared_ptr GetForegroundTaskRunner( v8::Isolate* isolate) override; + Platform::StackTracePrinter GetStackTracePrinter() override; + private: std::shared_ptr ForIsolate(v8::Isolate* isolate);