Closed
Description
Introduced in version 10.2.0 (found in versions 10.2.0..10.7.0)
Tiny snippet:
'use strict'
const { spawn } = require('child_process')
// Spawning a child with trace events enabled
// Segfaults when:
// - Destination file is missing OR
// - On any error thrown inside the file, like `throw new Error('foo')` or `require('module-not-found')`
const proc = spawn('node', ['non-existent.js'], {
env: Object.assign({}, process.env, {
NODE_OPTIONS: '--trace-events-enabled'
})
})
proc.once('exit', function (code, signal) {
console.log({ code, signal })
})
Execution:
km-mac:n-tmp km$ nvm use 10.7
Now using node v10.7.0 (npm v6.1.0)
km-mac:n-tmp km$ node segfault-issue.js
{ code: null, signal: 'SIGSEGV' }
# BROKEN
km-mac:n-tmp km$ nvm use 10.2
Now using node v10.2.0 (npm v5.6.0)
km-mac:n-tmp km$ node segfault-issue.js
{ code: null, signal: 'SIGSEGV' }
# BROKEN
km-mac:n-tmp km$ nvm use 10.1
Now using node v10.1.0 (npm v5.6.0)
km-mac:n-tmp km$ node segfault-issue.js
{ code: 1, signal: null }
# OK
km-mac:n-tmp km$ nvm use 10.2
Now using node v10.2.0 (npm v5.6.0)
km-mac:n-tmp km$ echo "throw new Error('foo')" > non-existent.js
km-mac:n-tmp km$ node segfault-issue.js
{ code: null, signal: 'SIGSEGV' }
# On error throw
km-mac:n-tmp km$ echo "require('foo')" > non-existent.js
km-mac:n-tmp km$ node segfault-issue.js
{ code: null, signal: 'SIGSEGV' }
# On ENOENT require
km-mac:n-tmp km$ echo "require('http')" > non-existent.js
km-mac:n-tmp km$ node segfault-issue.js
{ code: 0, signal: null }
# When contents are valid
km-mac:n-tmp km$ ls
node_trace.1.log non-existent.js segfault-issue.js
# Trace log was produced during one of these executions
Trace log file:
node_trace.1.log
OSX El Capitan 10.11.6
km-mac:n-tmp km$ uname -a
Darwin km-mac.local 15.6.0 Darwin Kernel Version 15.6.0: Thu Jun 21 20:07:40 PDT 2018; root:xnu-3248.73.11~1/RELEASE_X86_64 x86_64