New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

segfault-raub

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

segfault-raub - npm Package Compare versions

Comparing version 1.3.2 to 2.0.0

LICENSE_node-segfault-handler

4

index.js

@@ -7,5 +7,5 @@ 'use strict';

} else {
const { bin } = require('addon-tools-raub');
const { getBin } = require('addon-tools-raub');
const core = require(`./${bin}/segfault`);
const core = require(`./${getBin()}/segfault`);

@@ -12,0 +12,0 @@ global['segfault-raub'] = core;

'use strict';
const install = require('addon-tools-raub/install');
const { install } = require('addon-tools-raub');
const prefix = 'https://github.com/node-3d/segfault-raub/releases/download';
const tag = '1.3.0';
const tag = '2.0.0';
install(`${prefix}/${tag}`);
{
"author": "Luis Blanco <luisblanco1337@gmail.com>",
"name": "segfault-raub",
"version": "1.3.2",
"version": "2.0.0",
"description": "Catches SIGSEGV and prints diagnostic information",

@@ -21,3 +21,2 @@ "main": "index.js",

"files": [
"include",
"index.js",

@@ -27,2 +26,3 @@ "index.d.ts",

"LICENSE",
"LICENSE_node-segfault-handler",
"package.json",

@@ -34,27 +34,11 @@ "README.md"

"eslint": "eslint .",
"build": "cd src && node-gyp rebuild && cd ..",
"test": "jest --coverage=false --watch",
"test-ci": "jest --coverage=false --verbose",
"test-coverage": "rm -rf doc/jest && jest --coverage --silent"
"build-all": "cd src && node-gyp rebuild -j max --silent && node -e \"require('addon-tools-raub').cpbin('segfault')\" && cd ..",
"build-only": "cd src && node-gyp build -j max --silent && node -e \"require('addon-tools-raub').cpbin('segfault')\" && cd ..",
"test": "jest --coverage=false --watch --config=conf/jest.json",
"test-ci": "jest --ci --runInBand --coverage=false --forceExit --detectOpenHandles --config=conf/jest.json",
"test-coverage": "rm -rf doc/jest && jest --coverage --silent --config=conf/jest.json"
},
"jest": {
"moduleFileExtensions": [
"js",
"node"
],
"testMatch": [
"**/*.test.js"
],
"coverageDirectory": "doc/jest",
"coverageReporters": [
"lcov"
],
"collectCoverageFrom": [
"**/*.js",
"!**/*.test.js"
]
},
"engines": {
"node": ">=16.17.0",
"npm": ">=8.15.0"
"node": ">=18.12.1",
"npm": ">=8.19.2"
},

@@ -66,13 +50,12 @@ "repository": {

"dependencies": {
"addon-tools-raub": "^6.0.2",
"adm-zip": "^0.5.9"
"addon-tools-raub": "^7.0.0"
},
"devDependencies": {
"eslint-plugin-jest": "^27.1.6",
"eslint-plugin-jest": "^27.2.0",
"eslint-plugin-node": "^11.1.0",
"eslint": "^8.28.0",
"eslint": "^8.31.0",
"jest": "^29.3.1",
"node-addon-api": "^5.0.0",
"typescript": "^4.9.3"
"typescript": "^4.9.4"
}
}

@@ -5,3 +5,3 @@ # Segfault handler for Node.js

[![NPM](https://nodei.co/npm/segfault-raub.png?compact=true)](https://www.npmjs.com/package/segfault-raub)
[![NPM](https://badge.fury.io/js/segfault-raub.svg)](https://badge.fury.io/js/segfault-raub)
[![CodeFactor](https://www.codefactor.io/repository/github/node-3d/segfault-raub/badge)](https://www.codefactor.io/repository/github/node-3d/segfault-raub)

@@ -13,5 +13,6 @@

This module does nothing (zero perf impact) as long as Node is well-behaved.
If a **SIGSEGV** signal is raised, the module will print a native stack trace to both
**STDERR** and to the "segfault.log" file (if exists). If there is no such file, it
This module installs platform-specific **signal** listeners
(see `sigaction` for **Unix** and `SetUnhandledExceptionFilter` for **Windows**).
Whenever a signal is raised, the module prints a native stack trace (if possible) to both
**STDERR** and to the "**segfault.log**" file (if it exists). If there is no such file, it
**won't be created**, so it is up to you if the log-file is needed.

@@ -26,5 +27,4 @@

Just require the module and that's it. You may require it as many times you want,
but the **SIGSEGV** hook will only be set once. There are no calls required, and
no options.
A zero-setup is available: just require the module and it comes pre-equipped with several
signal listeners enabled by default.

@@ -35,5 +35,46 @@ ```javascript

There is one exported function though:
> Note: if your project tree contains multiple versions of this module, the first one imported
will seize `global['segfault-raub']`. The rest of them will only re-export `global['segfault-raub']`
and **WILL NOT** import their own **binaries**.
A more detailed manual setup is available and explained below.
## Enabling Signals
As listed below, some signals (platform specific) are enabled by default. But they can be
enabled/disabled manually:
Example:
```javascript
const {
setSignal,
EXCEPTION_ACCESS_VIOLATION, SIGSEGV,
EXCEPTION_BREAKPOINT, SIGTRAP,
} = require('segfault-raub');
setSignal(EXCEPTION_ACCESS_VIOLATION, false);
setSignal(SIGSEGV, false);
setSignal(EXCEPTION_BREAKPOINT, true);
setSignal(SIGTRAP, true);
```
On **Windows**, all the **Unix** signals are `null`, and the opposite is true.
Passing `null` as the first parameter to `setSignal` **has no effect and is safe**.
## Demo Methods
These are be helpful to see how the signals are reported and if the log files are being written properly.
* `causeSegfault` - Causes a memory access violation.
* `causeDivisionInt` - Divides an integer by zero.
* `causeOverflow` - Runs infinite recursion (stack overflow).
* `causeIllegal` - Raises an "illegal instruction" exception.
Example:
```javascript
const { causeSegfault } = require('segfault-raub');

@@ -43,5 +84,70 @@ causeSegfault();

In doing so, you will cause a segfault (accessing 0x01 pointer), and see how it goes.
## Windows Signals
| Signal | Enabled | Description |
| :--- | :---: | :--- |
| EXCEPTION_ACCESS_VIOLATION | yes | Memory access was denied. |
| EXCEPTION_ARRAY_BOUNDS_EXCEEDED | yes | Array was accessed with an illegal index. |
| EXCEPTION_INT_DIVIDE_BY_ZERO | yes | Attempt to divide by an integer divisor of 0. |
| EXCEPTION_ILLEGAL_INSTRUCTION | yes | Attempt to execute an illegal instruction. |
| EXCEPTION_NONCONTINUABLE_EXCEPTION | yes | Can't continue after an exception. |
| EXCEPTION_STACK_OVERFLOW | yes | The thread used up its stack. |
| EXCEPTION_INVALID_HANDLE | yes | An invalid handle was specified. |
| EXCEPTION_FLT_DIVIDE_BY_ZERO | no | Attempt to divide by a float divisor of 0.f. |
| EXCEPTION_DATATYPE_MISALIGNMENT | no | A datatype misalignment was detected. |
| EXCEPTION_BREAKPOINT | no | A Breakpoint has been reached. |
| EXCEPTION_SINGLE_STEP | no | Continue single-stepping execution. |
| EXCEPTION_FLT_DENORMAL_OPERAND | no | One of the operands is denormal. |
| EXCEPTION_FLT_INEXACT_RESULT | no | The result cannot be represented exactly. |
| EXCEPTION_FLT_INVALID_OPERATION | no | Floating-point invalid operation. |
| EXCEPTION_FLT_OVERFLOW | no | The exponent of operation is too large. |
| EXCEPTION_FLT_STACK_CHECK | no | The Stack gone bad after a float operation. |
| EXCEPTION_FLT_UNDERFLOW | no | The exponent of operation is too low. |
| EXCEPTION_INT_OVERFLOW | no | The result of operation is too large. |
| EXCEPTION_PRIV_INSTRUCTION | no | Operation is not allowed in current mode. |
| EXCEPTION_IN_PAGE_ERROR | no | Can't access a memory page. |
| EXCEPTION_INVALID_DISPOSITION | no | Invalid disposition returned. |
| EXCEPTION_GUARD_PAGE | no | Accessing PAGE_GUARD-allocated modifier. |
## Unix Signals
| Signal | Handling | Enabled | Description |
| :--- | :---: | :---: | :--- |
| SIGABRT | A | yes | Process abort signal. |
| SIGFPE | A | yes | Erroneous arithmetic operation. |
| SIGSEGV | A | yes | Invalid memory reference. |
| SIGILL | A | yes | Illegal instruction. |
| SIGBUS | A | yes | Access to an undefined portion of a memory object. |
| SIGTERM | T | no | Termination signal. |
| SIGINT | T | no | Terminal interrupt signal. |
| SIGALRM | T | no | Alarm clock. |
| SIGCHLD | I | no | Child process terminated, stopped, or continued. |
| SIGCONT | C | no | Continue executing, if stopped. |
| SIGHUP | T | no | Hangup. |
| SIGKILL | T | no | Kill (cannot be caught or ignored). |
| SIGPIPE | T | no | Write on a pipe with no one to read it. |
| SIGQUIT | A | no | Terminal quit signal. |
| SIGSTOP | S | no | Stop executing (cannot be caught or ignored). |
| SIGTSTP | S | no | Terminal stop signal. |
| SIGTTIN | S | no | Background process attempting read. |
| SIGTTOU | S | no | Background process attempting write. |
| SIGUSR1 | T | no | User-defined signal 1. |
| SIGUSR2 | T | no | User-defined signal 2. |
| SIGPROF | T | no | Profiling timer expired. |
| SIGSYS | A | no | Bad system call. |
| SIGTRAP | A | no | Trace/breakpoint trap. |
| SIGURG | I | no | High bandwidth data is available at a socket. |
| SIGVTALRM | T | no | Virtual timer expired. |
| SIGXCPU | A | no | CPU time limit exceeded. |
| SIGXFSZ | A | no | File size limit exceeded. |
* `T` - Abnormal termination of the process.
* `A` - Abnormal termination of the process with additional actions.
* `I` - Ignore the signal.
* `S` - Stop the process.
* `C` - Continue the process, if it is stopped; otherwise, ignore the signal.
## Legal notice

@@ -48,0 +154,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc