Skip to content

Commit 8fec65d

Browse files
authored
test: normalize Windows crash in debugger test normalization
The inspector can crash on teardown when the debuggee exits quickly, previously we ignored it for debugger tests as that's likely an upstream issue unrelated to Node.js's own debugger utilities, but the detection only matches patternsf on UNIX-y platforms. On Windows this manifests as exit code 3221225477 (0xC0000005 STATUS_ACCESS_VIOLATION) instead of SIGSEGV. Extend the helper to recognize and normalize both variants. Signed-off-by: Joyee Cheung <joyeec9h3@gmail.com> PR-URL: #64332 Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Filip Skokan <panva.ip@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 7360fad commit 8fec65d

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

test/common/debugger-probe.js

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,33 @@ const assert = require('assert');
44
const { spawnSyncAndExit } = require('./child_process');
55

66
// Work around a pre-existing inspector issue: if the debuggee exits too quickly
7-
// the inspector can segfault while tearing down. For now normalize the segfault
7+
// the inspector can crash while tearing down. For now normalize the crash
88
// back to the expected terminal event (e.g. "completed" or "miss")
99
// until the upstream bug is fixed.
1010
// See https://github.com/nodejs/node/issues/62765
1111
// https://github.com/nodejs/node/issues/58245
12+
// The crash shows up as with exit code 3221225477 on Windows, or signal
13+
// SIGSEGV on other platforms.
1214
const probeTargetExitSignal = 'SIGSEGV';
15+
// 0xC0000005 STATUS_ACCESS_VIOLATION on Windows
16+
const probeTargetExitCode = 3221225477;
1317

1418
function isProbeSegvTeardown(result) {
1519
if (result?.event !== 'error') { return false; }
1620
const error = result.error;
17-
if (error?.signal !== probeTargetExitSignal) { return false; }
21+
if (error?.signal !== probeTargetExitSignal && error?.exitCode !== probeTargetExitCode) { return false; }
1822
return error.code === 'probe_target_exit' || error.code === 'probe_failure';
1923
}
2024

2125
function findProbeSegvTeardownLine(output) {
2226
const signalPrefix = `Target exited with signal ${probeTargetExitSignal}`;
23-
if (output.startsWith(signalPrefix)) { return 0; }
24-
const idx = output.indexOf(`\n${signalPrefix}`);
25-
return idx === -1 ? -1 : idx + 1;
27+
const codePrefix = `Target exited with code ${probeTargetExitCode}`;
28+
for (const prefix of [signalPrefix, codePrefix]) {
29+
if (output.startsWith(prefix)) { return 0; }
30+
const idx = output.indexOf(`\n${prefix}`);
31+
if (idx !== -1) { return idx + 1; }
32+
}
33+
return -1;
2634
}
2735

2836
// Replace volatile fields in a probe report (stack frames, Node.js version,

0 commit comments

Comments
 (0)