|
| 1 | +// Check that abrupt termination when async call stack recording is enabled |
| 2 | +// does not segfault the process. |
| 3 | +'use strict'; |
| 4 | +const common = require('../common'); |
| 5 | +common.skipIfInspectorDisabled(); |
| 6 | +common.skipIf32Bits(); |
| 7 | + |
| 8 | +const { strictEqual } = require('assert'); |
| 9 | +const eyecatcher = 'nou, houdoe he?'; |
| 10 | + |
| 11 | +if (process.argv[2] === 'child') { |
| 12 | + const { Session } = require('inspector'); |
| 13 | + const { promisify } = require('util'); |
| 14 | + const { registerAsyncHook } = process.binding('inspector'); |
| 15 | + (async () => { |
| 16 | + let enabled = 0; |
| 17 | + registerAsyncHook(() => ++enabled, () => {}); |
| 18 | + const session = new Session(); |
| 19 | + session.connect(); |
| 20 | + session.post = promisify(session.post); |
| 21 | + await session.post('Debugger.enable'); |
| 22 | + strictEqual(enabled, 0); |
| 23 | + await session.post('Debugger.setAsyncCallStackDepth', { maxDepth: 42 }); |
| 24 | + strictEqual(enabled, 1); |
| 25 | + throw new Error(eyecatcher); |
| 26 | + })(); |
| 27 | +} else { |
| 28 | + const { spawnSync } = require('child_process'); |
| 29 | + const options = { encoding: 'utf8' }; |
| 30 | + const proc = spawnSync(process.execPath, [__filename, 'child'], options); |
| 31 | + strictEqual(proc.status, 0); |
| 32 | + strictEqual(proc.signal, null); |
| 33 | + strictEqual(proc.stderr.includes(eyecatcher), true); |
| 34 | +} |
0 commit comments