summaryrefslogtreecommitdiff
path: root/test/sequential/test-inspector-async-call-stack-abort.js
diff options
context:
space:
mode:
authorBen Noordhuis <info@bnoordhuis.nl>2017-12-08 15:33:41 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2017-12-12 12:48:37 -0200
commit88a9e2df859c9de8a3b2d0cca9862ee00478c863 (patch)
treef9fac33e9d54fb30fe4ac39a591f2210b5a702e4 /test/sequential/test-inspector-async-call-stack-abort.js
parent93656f4366bcb6084cae63aeb97a63d3634bac2b (diff)
downloadandroid-node-v8-88a9e2df859c9de8a3b2d0cca9862ee00478c863.tar.gz
android-node-v8-88a9e2df859c9de8a3b2d0cca9862ee00478c863.tar.bz2
android-node-v8-88a9e2df859c9de8a3b2d0cca9862ee00478c863.zip
src: fix inspector nullptr deref on abrupt exit
Fix a nullptr dereference on abrupt termination when async call stack recording is enabled. Bug discovered while trying to write a regression test for the bug fix in commit df79b7d821 ("src: fix missing handlescope bug in inspector".) PR-URL: https://github.com/nodejs/node/pull/17577 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Eugene Ostroukhov <eostroukhov@google.com>
Diffstat (limited to 'test/sequential/test-inspector-async-call-stack-abort.js')
-rw-r--r--test/sequential/test-inspector-async-call-stack-abort.js34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/sequential/test-inspector-async-call-stack-abort.js b/test/sequential/test-inspector-async-call-stack-abort.js
new file mode 100644
index 0000000000..1ec46ab3cf
--- /dev/null
+++ b/test/sequential/test-inspector-async-call-stack-abort.js
@@ -0,0 +1,34 @@
+// Check that abrupt termination when async call stack recording is enabled
+// does not segfault the process.
+'use strict';
+const common = require('../common');
+common.skipIfInspectorDisabled();
+common.skipIf32Bits();
+
+const { strictEqual } = require('assert');
+const eyecatcher = 'nou, houdoe he?';
+
+if (process.argv[2] === 'child') {
+ const { Session } = require('inspector');
+ const { promisify } = require('util');
+ const { registerAsyncHook } = process.binding('inspector');
+ (async () => {
+ let enabled = 0;
+ registerAsyncHook(() => ++enabled, () => {});
+ const session = new Session();
+ session.connect();
+ session.post = promisify(session.post);
+ await session.post('Debugger.enable');
+ strictEqual(enabled, 0);
+ await session.post('Debugger.setAsyncCallStackDepth', { maxDepth: 42 });
+ strictEqual(enabled, 1);
+ throw new Error(eyecatcher);
+ })();
+} else {
+ const { spawnSync } = require('child_process');
+ const options = { encoding: 'utf8' };
+ const proc = spawnSync(process.execPath, [__filename, 'child'], options);
+ strictEqual(proc.status, 0);
+ strictEqual(proc.signal, null);
+ strictEqual(proc.stderr.includes(eyecatcher), true);
+}