Coder Social home page Coder Social logo

conradirwin / node-segfault-handler Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ddopson/node-segfault-handler

0.0 3.0 0.0 106 KB

Tool for debugging native Node.js modules and getting stack traces when things go wrong.

Python 6.78% JavaScript 20.83% C++ 72.39%

node-segfault-handler's Introduction

Overview

This module catches segfaults and sigaborts. It's useful for debugging native Node.js C/C++ code, and is safe to use in a production environment.

Normally when a C program crashes, the only way to tell is to examine /var/log/syslog at the time of the crash, with this addons installed it writes a report to the filesystem and to STDERR.

var Segfault = require('segfault');

Segfault.registerHandler("/path/to/write/segfaults");

Segfault.causeSegfault(); // simulates a buggy native module that dereferences NULL

Obviously, you would only include the first two lines in your own code; the third is for testing purposes and to demonstrate functionality.

After running the above sample, you will see a stacktrace that looks like:

PID 67926 received SIGSEGV for address: 0x0
0   segfault-handler-native.node        0x00000001007e83d6 _ZL16segfault_handleriP9__siginfoPv + 235
1   libSystem.B.dylib                   0x00007fff844d11ba _sigtramp + 26
2   ???                                 0x00007fff5fc404a0 0x0 + 140734800069792
3   segfault-handler-native.node        0x00000001007e80fd _Z22segfault_stack_frame_2v + 9
4   segfault-handler-native.node        0x00000001007e82d4 _Z13CauseSegfaultRKN2v89ArgumentsE + 17
5   node                                0x00000001000a45de _ZN2v88internalL21Builtin_HandleApiCallENS0_12_GLOBAL__N_116BuiltinArgumentsILNS0_21BuiltinExtraArgumentsE1EEEPNS0_7IsolateE + 430

Now you can start debugging using tools like "objdump -dS module.node" to try and sort out what the stack actually means. Sometimes, just identifying which native module is causing problems is the biggest win.

Cheers, enjoy. And happy hunting.

Installing

npm install segfault --save

License

This is a slight modification of the node-segfault-handler code, thanks Dave!.

This software is licensed for use under the WTFPL; version 2 if it's a lawyer asking. Though if you make good use of this or any of my other tools, I'd appreciate an email letting me know what you used it for or how you stumbled across it.

--- Dave

node-segfault-handler's People

Contributors

ddopson avatar conradirwin avatar byronclark avatar mitar avatar hb9cwp avatar tpxp avatar no9 avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.