{"id":17291363,"url":"https://github.com/shiranuit/node-segfault-handler","last_synced_at":"2025-04-14T11:25:37.471Z","repository":{"id":45653778,"uuid":"420203127","full_name":"Shiranuit/node-segfault-handler","owner":"Shiranuit","description":"A C++ Node.js module that helps gathering informations on segmentation fault","archived":false,"fork":false,"pushed_at":"2023-01-03T10:33:56.000Z","size":98,"stargazers_count":15,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-12T00:43:12.085Z","etag":null,"topics":["alpine-linux","cplusplus","crash","debugging-tool","hacktoberfest","libunwind","linux","nodejs","segfault","stacktrace"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Shiranuit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-22T18:26:58.000Z","updated_at":"2024-12-24T19:00:57.000Z","dependencies_parsed_at":"2023-02-01T05:45:19.727Z","dependency_job_id":null,"html_url":"https://github.com/Shiranuit/node-segfault-handler","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shiranuit%2Fnode-segfault-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shiranuit%2Fnode-segfault-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shiranuit%2Fnode-segfault-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shiranuit%2Fnode-segfault-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shiranuit","download_url":"https://codeload.github.com/Shiranuit/node-segfault-handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248870289,"owners_count":21175010,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["alpine-linux","cplusplus","crash","debugging-tool","hacktoberfest","libunwind","linux","nodejs","segfault","stacktrace"],"created_at":"2024-10-15T10:40:51.659Z","updated_at":"2025-04-14T11:25:37.450Z","avatar_url":"https://github.com/Shiranuit.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-segfault-handler\n\nA C++ Node.js module that helps gathering informations on segmentation fault\n\n## Supported Platforms\n\n| Linux | Linux Alpine | Windows | MacOS |\n|:-----:|:------------:|:-------:|:-----:|\n| Supported    | Supported           |      Partial | Partial    |\n\n## Installation\n\n```bash\nsudo apt install pkg-config libunwind-dev\n```\n\n```\nnpm install node-segfault-handler\n```\n\n## Requirements\n\nThe library `libunwind-dev` is `optionnal`, if not present on your system the library `node-segfault-handler` will still compile but you wont have have the native stacktraces printed when a segfault occurs, you will only see the javascript stacktraces from V8.\n\nThe package `node-segfault-handler` relies on `pkg-config` to detect if `libunwind-dev` is installed, if `pkg-config` is not present on your system `node-segfault-handler` will still compile but you wont have have the native stacktraces printed when a segfault occurs, you will only see the javascript stacktraces from V8.\n\n### Compilation\n\nOn Linux / MacOS you need to have `GCC` or `Clang` installed\n\nOn Windows you need to have either `MSVC` or `MinGW` installed\n\n## Platform Specifications\n### Linux \u0026 Linux Alpine\nIf the library `libunwind-dev` is installed on your system, the library `node-segfault-handler` will be compiled with it and the native stacktraces will be printed when a segfault occurs.\n\nIn all cases, if the library `libunwind-dev` is installed or not, you will still have the Javascript Stacktraces from V8 printed.\n### Other\nNative Stacktraces are always disabled on other OS than Linux, but you will still have the Javascript Stacktraces from V8 printed.\n\n## Usage\n\n```ts\nlet segfaultHandler = require('node-segfault-handler');\n\n/**\n * Once a segfault occurs, \n * stacktraces from V8 and native stacktraces will be printed to the STDERR or you can provide a path to write to.\n * \n * @param path File path, if null write to stderr\n */ \nsegfaultHandler.registerHandler(path: string?);\n\n\n// Simulate a segfault from a native module\nsegfaultHandler.segfault();\n\n```\n\n## Example\n\n```js\nlet segfaultHandler = require('node-segfault-handler');\n\nfunction foo() {\n  bar();\n}\n\nfunction bar() {\n  segfaultHandler.segfault();\n}\n\nfunction main() {\n  segfaultHandler.registerHandler();\n  foo();\n}\n\nmain();\n```\n\n```\n=========== Caught a Segmentation Fault [pid=14435] ===========\n-----[ Native Stacktraces ]-----\n[pc=0x00007f17bffff7bf, sp=0x00007ffdf48ba120] in segfault_handler(int)+0x4f\n[pc=0x00007f17bfad7210, sp=0x00007ffdf48ba140] in killpg+0x40\n[pc=0x00007f17bffff844, sp=0x00007ffdf48ba6f8] in Segfault(Nan::FunctionCallbackInfo\u003cv8::Value\u003e const\u0026)+0x4\n[pc=0x00007f17bffff90c, sp=0x00007ffdf48ba700] in Nan::imp::FunctionCallbackWrapper(v8::FunctionCallbackInfo\u003cv8::Value\u003e const\u0026)+0xac\n[pc=0x0000000000c065f9, sp=0x00007ffdf48ba760] in v8::internal::MaybeHandle\u003cv8::internal::Object\u003e v8::internal::(anonymous namespace)::HandleApiCallHelper\u003cfalse\u003e(v8::internal::Isolate*, v8::internal::Handle\u003cv8::internal::HeapObject\u003e, v8::internal::Handle\u003cv8::internal::HeapObject\u003e, v8::internal::Handle\u003cv8::internal::FunctionTemplateInfo\u003e, v8::internal::Handle\u003cv8::internal::Object\u003e, v8::internal::BuiltinArguments)+0x1c9\n[pc=0x0000000000c083e7, sp=0x00007ffdf48ba8a0] in v8::internal::Builtin_HandleApiCall(int, unsigned long*, v8::internal::Isolate*)+0xb7\n[pc=0x000000000140df99, sp=0x00007ffdf48ba920] in Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit+0x39\n[pc=0x0000000001393724, sp=0x00007ffdf48ba930] in Builtins_InterpreterEntryTrampoline+0x2a4\n[pc=0x0000000001393724, sp=0x00007ffdf48ba940] in Builtins_InterpreterEntryTrampoline+0x2a4\n[pc=0x0000000001393724, sp=0x00007ffdf48ba950] in Builtins_InterpreterEntryTrampoline+0x2a4\n[pc=0x0000000001393724, sp=0x00007ffdf48ba960] in Builtins_InterpreterEntryTrampoline+0x2a4\n[pc=0x0000000001393724, sp=0x00007ffdf48ba970] in Builtins_InterpreterEntryTrampoline+0x2a4\n[pc=0x0000000001393724, sp=0x00007ffdf48ba980] in Builtins_InterpreterEntryTrampoline+0x2a4\n[pc=0x0000000001393724, sp=0x00007ffdf48ba990] in Builtins_InterpreterEntryTrampoline+0x2a4\n[pc=0x0000000001393724, sp=0x00007ffdf48ba9a0] in Builtins_InterpreterEntryTrampoline+0x2a4\n[pc=0x0000000001393724, sp=0x00007ffdf48ba9b0] in Builtins_InterpreterEntryTrampoline+0x2a4\n[pc=0x0000000001393724, sp=0x00007ffdf48ba9c0] in Builtins_InterpreterEntryTrampoline+0x2a4\n[pc=0x0000000001390c9d, sp=0x00007ffdf48ba9d0] in Builtins_JSEntryTrampoline+0x5d\n[pc=0x0000000001390a78, sp=0x00007ffdf48ba9e0] in Builtins_JSEntry+0x78\n[pc=0x0000000000ceca30, sp=0x00007ffdf48ba9f0] in v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const\u0026)+0x1b0\n[pc=0x0000000000cecee8, sp=0x00007ffdf48bb000] in v8::internal::Execution::Call(v8::internal::Isolate*, v8::internal::Handle\u003cv8::internal::Object\u003e, v8::internal::Handle\u003cv8::internal::Object\u003e, int, v8::internal::Handle\u003cv8::internal::Object\u003e*)+0x58\n[pc=0x0000000000bac32b, sp=0x00007ffdf48bb090] in v8::Function::Call(v8::Local\u003cv8::Context\u003e, v8::Local\u003cv8::Value\u003e, int, v8::Local\u003cv8::Value\u003e*)+0x16b\n[pc=0x00000000009e6e41, sp=0x00007ffdf48bb1c0] in node::ExecuteBootstrapper(node::Environment*, char const*, std::vector\u003cv8::Local\u003cv8::String\u003e, std::allocator\u003cv8::Local\u003cv8::String\u003e \u003e \u003e*, std::vector\u003cv8::Local\u003cv8::Value\u003e, std::allocator\u003cv8::Local\u003cv8::Value\u003e \u003e \u003e*)+0x71\n[pc=0x00000000009e7156, sp=0x00007ffdf48bb240] in node::StartExecution(node::Environment*, char const*)+0x216\n[pc=0x00000000009e8518, sp=0x00007ffdf48bb310] in node::StartExecution(node::Environment*, std::function\u003cv8::MaybeLocal\u003cv8::Value\u003e (node::StartExecutionCallbackInfo const\u0026)\u003e)+0x568\n[pc=0x0000000000988f01, sp=0x00007ffdf48bb3a0] in node::LoadEnvironment(node::Environment*)+0x61\n[pc=0x0000000000a5d704, sp=0x00007ffdf48bb400] in node::NodeMainInstance::Run()+0x154\n[pc=0x00000000009eab6c, sp=0x00007ffdf48bb520] in node::Start(int, char**)+0x2ac\n[pc=0x00007f17bfab80b3, sp=0x00007ffdf48bb6a0] in __libc_start_main+0xf3\n[pc=0x0000000000981fe5, sp=0x00007ffdf48bb770] in _start+0x29\n\n---[ V8 JavaScript Stacktraces ]---\nat bar (/home/shiranuit/node-segfault-handler/tests/test.js:8:19)\nat foo (/home/shiranuit/node-segfault-handler/tests/test.js:4:3)\nat main (/home/shiranuit/node-segfault-handler/tests/test.js:13:3)\nat (null) (/home/shiranuit/node-segfault-handler/tests/test.js:16:1)\nat Module._compile (internal/modules/cjs/loader.js:999:30)\nat Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\nat Module.load (internal/modules/cjs/loader.js:863:32)\nat Module._load (internal/modules/cjs/loader.js:708:14)\nat executeUserEntryPoint (internal/modules/run_main.js:60:12)\nat (null) (internal/main/run_main_module.js:17:47)\n============================================================\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiranuit%2Fnode-segfault-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshiranuit%2Fnode-segfault-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshiranuit%2Fnode-segfault-handler/lists"}