forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
debugger: guard against call from non-node context
Fix a segmentation fault when the debug message handler was called from a context without an associated `node::Environment`. Fixes: nodejs#4261 Fixes: nodejs#4322
- Loading branch information
1 parent
ae5bcf9
commit b452b7f
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const spawn = require('child_process').spawn; | ||
|
||
const args = [`--debug`, `--debug-port=${common.PORT}`, `--interactive`]; | ||
const proc = spawn(process.execPath, args, { stdio: 'pipe' }); | ||
proc.stdin.write(` | ||
util.inspect(Promise.resolve(42)); | ||
util.inspect(Promise.resolve(1337)); | ||
.exit | ||
`); | ||
proc.on('exit', common.mustCall((exitCode, signalCode) => { | ||
assert.strictEqual(exitCode, 0); | ||
assert.strictEqual(signalCode, null); | ||
})); | ||
let stdout = ''; | ||
proc.stdout.setEncoding('utf8'); | ||
proc.stdout.on('data', data => stdout += data); | ||
process.on('exit', () => { | ||
assert(stdout.includes('Promise { 42 }')); | ||
assert(stdout.includes('Promise { 1337 }')); | ||
}); |