11cb0ef41Sopenharmony_ci// Check that abrupt termination when async call stack recording is enabled 21cb0ef41Sopenharmony_ci// does not segfault the process. 31cb0ef41Sopenharmony_ci'use strict'; 41cb0ef41Sopenharmony_ciconst common = require('../common'); 51cb0ef41Sopenharmony_cicommon.skipIfInspectorDisabled(); 61cb0ef41Sopenharmony_cicommon.skipIf32Bits(); 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ciconst { strictEqual } = require('assert'); 91cb0ef41Sopenharmony_ciconst eyecatcher = 'nou, houdoe he?'; 101cb0ef41Sopenharmony_ci 111cb0ef41Sopenharmony_ciif (process.argv[2] === 'child') { 121cb0ef41Sopenharmony_ci const { Session } = require('inspector'); 131cb0ef41Sopenharmony_ci const { promisify } = require('util'); 141cb0ef41Sopenharmony_ci const { internalBinding } = require('internal/test/binding'); 151cb0ef41Sopenharmony_ci const { registerAsyncHook } = internalBinding('inspector'); 161cb0ef41Sopenharmony_ci (async () => { 171cb0ef41Sopenharmony_ci let enabled = 0; 181cb0ef41Sopenharmony_ci registerAsyncHook(() => ++enabled, () => {}); 191cb0ef41Sopenharmony_ci const session = new Session(); 201cb0ef41Sopenharmony_ci session.connect(); 211cb0ef41Sopenharmony_ci session.post = promisify(session.post); 221cb0ef41Sopenharmony_ci await session.post('Debugger.enable'); 231cb0ef41Sopenharmony_ci strictEqual(enabled, 0); 241cb0ef41Sopenharmony_ci await session.post('Debugger.setAsyncCallStackDepth', { maxDepth: 42 }); 251cb0ef41Sopenharmony_ci strictEqual(enabled, 1); 261cb0ef41Sopenharmony_ci throw new Error(eyecatcher); 271cb0ef41Sopenharmony_ci })().finally(common.mustCall()); 281cb0ef41Sopenharmony_ci} else { 291cb0ef41Sopenharmony_ci const { spawnSync } = require('child_process'); 301cb0ef41Sopenharmony_ci const options = { encoding: 'utf8' }; 311cb0ef41Sopenharmony_ci const proc = spawnSync( 321cb0ef41Sopenharmony_ci process.execPath, ['--expose-internals', __filename, 'child'], options); 331cb0ef41Sopenharmony_ci strictEqual(proc.status, 1); 341cb0ef41Sopenharmony_ci strictEqual(proc.signal, null); 351cb0ef41Sopenharmony_ci strictEqual(proc.stderr.includes(eyecatcher), true); 361cb0ef41Sopenharmony_ci} 37