-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
src: adjust windows abort behavior to make sense #13947
Conversation
Conservatively marking as |
@@ -21,7 +21,7 @@ function run(flags, signals) { | |||
child.on('exit', common.mustCall(function(code, sig) { | |||
if (common.isWindows) { | |||
if (signals) | |||
assert.strictEqual(code, 3); | |||
assert.strictEqual(code, 3221225477); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you replace this with 0xC0000005
(better google results)
test/common/index.js
Outdated
if (exports.isWindows) | ||
expectedExitCodes = [3221225477, 3]; | ||
expectedExitCodes = [3221225477, 134]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same 0xC0000005
@nodejs/platform-windows |
@jkantr One request, add |
/cc @nodejs/release how do we decide the semver level? |
} | ||
|
||
// --max-old-space-size=3 is the min 'old space' in v8, explodes fast | ||
const cmd = `"${process.argv[0]}" --max-old-space-size=3 "${process.argv[1]}"`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could use process.execPath
and __filename
.
fn(2); | ||
} | ||
|
||
// --max-old-space-size=3 is the min 'old space' in v8, explodes fast |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit: v8
-> V8
. This will help distinguish between Node.js 8 and V8 JavaScript engine.
|
||
// --max-old-space-size=3 is the min 'old space' in v8, explodes fast | ||
const cmd = `"${process.argv[0]}" --max-old-space-size=3 "${process.argv[1]}"`; | ||
exec(`${cmd} heapBomb`, (err) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please wrap the callback with common.mustCall()
.
const cmd = `"${process.argv[0]}" --max-old-space-size=3 "${process.argv[1]}"`; | ||
exec(`${cmd} heapBomb`, (err) => { | ||
const msg = `Wrong exit code of ${err.code}! Expected 134 for abort`; | ||
assert.strictEqual(err.code, 134, msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth a short comment explaining why common.nodeProcessAborted()
is not used.
If we cannot prove either way (ability / inability to configure Windows to collect dump on abort) I suggest we document on the lines of :
|
This change will stop windows from even attempting a core dump. It could be restored with an explicit call to MiniDumpWriteDump |
@refack - right, so the question is: do we follow the doc (abort program with dump on uncaught exception) or make this change and amend the doc to that effect. My point is: if Windows never dumped a core on aborted node before, or we don't know of anyone reporting that as an issue, I think we are good with this change, with the doc reflecting the change. If we get issues that require dump inspection, we can always bring an in-process dumping feature through MiniDumpWriteDump. Thoughts? |
/cc @nodejs/post-mortem |
On Windows libuv disables WER and thus also dumping cores (src/win/core.c:177). From a quick search it looks like it is not enabled anywhere else in the codebase. |
thanks @bzoz . And that piece of code is around there since 2011, so we are good in terms of core dump. in terms of doc - while it looks clean to state this fact explicitly, I am fine with this change as it is. |
test failures seem unrelated: FYI - @refack |
@gireeshpunathil Yes, these are known problems, even though the latter should be fixed now, ref #13986. |
I've found this black magic: https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/setting-and-clearing-flags-for-silent-process-exit |
RE last massage: black magic still works after this PR 👍 ping @nodejs/ctc PTAL, this needs another review |
@refack - great, that is a good news! Where do I set the Silent Exit Flag? gflags.exe? I could not locate it in any of my Win 7/10 systems. Is it an external download? |
The "good" |
CI to make sure it's still fresh: https://ci.nodejs.org/job/node-test-pull-request/9052/ |
@nodejs/ctc this needs another review, PTAL |
Aside: The wait to get CTC reviews for this may be a sign that we need more Windows representation on CTC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as its SemVer Major seems good to me.
@jkantr after the long wait we got the 2 CTC approval, but a failing test came up could you take a look? not ok 1 async-hooks/test-callback-error
---
duration_ms: 0.631
severity: fail
stack: |-
start case 1
end case 1: 131.106ms
start case 2
end case 2: 130.250ms
start case 3
end case 3: 6.412ms
assert.js:42
throw new errors.AssertionError({
^
AssertionError [ERR_ASSERTION]: 134 === 3
at ChildProcess.child.on (c:\workspace\node-test-binary-windows\RUN_SUBSET\0\VS_VERSION\vcbt2015\label\win10\test\async-hooks\test-callback-error.js:104:14)
at emitTwo (events.js:125:13)
at ChildProcess.emit (events.js:213:7)
at maybeClose (internal/child_process.js:929:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:212:5)
... |
This has two CTC approvals, etc. Any reason this shouldn't land? |
There's still one failing test, but I've talked to @jkantr about it... |
042bf12
to
f4186dc
Compare
All CI fails are known flakes or infra problems |
f4186dc
to
8f6b762
Compare
Raising SIGABRT is handled in the CRT in windows, calling _exit() with ambiguous code "3" by default. This adjustment to the abort behavior gives a more sane exit code on abort, by calling _exit directly with code 134. PR-URL: nodejs#13947 Fixes: nodejs#12271 Refs: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/abort Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
8f6b762
to
80ebb42
Compare
Extra sanity test on |
Raising SIGABRT is handled in the CRT in windows, calling _exit()
with ambiguous code "3" by default.
This adjustment to the abort behavior gives a more sane exit code
on abort, by calling _exit() directly with code 134.
I added a test I used initially in reference to recreating #12271 but it may be moot to merge.
Fixes: #12271
Refs: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/abort
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
src