-
-
Notifications
You must be signed in to change notification settings - Fork 36.4k
src: add SetAbortHandler #64684
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
Open
maxhfisher
wants to merge
8
commits into
nodejs:main
Choose a base branch
from
maxhfisher:aborthandler
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
src: add SetAbortHandler #64684
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c5548d3
src: add SetAbortHandler
maxhfisher 0684453
fix: fix lint
maxhfisher 309902e
fix: respond to PR comments
maxhfisher 71e66f8
fix: Update default abort message
maxhfisher 6b87c15
fix: Split handler arguments into location and message
maxhfisher f579940
Merge branch 'nodejs:main' into aborthandler
maxhfisher 8b881e0
fix: Be more clear about null arguments in abort handler
maxhfisher 455cbed
fix: Prose
maxhfisher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #include <node.h> | ||
| #include <v8.h> | ||
| #include <cstdio> | ||
|
|
||
| namespace { | ||
| void TestAbortHandler(const char* /*location*/, const char* /*message*/) { | ||
| fputs("CUSTOM_ABORT_HANDLER_RAN\n", stderr); | ||
| fflush(stderr); | ||
| } | ||
|
|
||
| void InstallAbortHandler(const v8::FunctionCallbackInfo<v8::Value>&) { | ||
| node::SetAbortHandler(TestAbortHandler); | ||
| } | ||
| } // namespace | ||
|
|
||
| NODE_MODULE_INIT() { | ||
| NODE_SET_METHOD(exports, "installAbortHandler", InstallAbortHandler); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| 'targets': [ | ||
| { | ||
| 'target_name': 'binding', | ||
| 'sources': [ 'binding.cc' ], | ||
| 'includes': ['../common.gypi'], | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| 'use strict'; | ||
| const common = require('../../common'); | ||
| const assert = require('assert'); | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
| const { exec } = require('child_process'); | ||
|
|
||
| const bindingPath = path.resolve( | ||
| __dirname, 'build', common.buildType, 'binding.node'); | ||
|
|
||
| if (!fs.existsSync(bindingPath)) | ||
| common.skip('binding not built yet'); | ||
|
|
||
| if (process.argv[2] === 'child') { | ||
| const binding = require(bindingPath); | ||
| binding.installAbortHandler(); | ||
| process.abort(); | ||
| return; | ||
| } | ||
|
|
||
| const escapedArgs = | ||
| common.escapePOSIXShell`"${process.execPath}" "${__filename}" child`; | ||
| if (!common.isWindows) { | ||
| // Do not create core files, as it can take a lot of disk space on | ||
| // continuous testing and developers' machines. | ||
| escapedArgs[0] = 'ulimit -c 0 && ' + escapedArgs[0]; | ||
| } | ||
|
|
||
| exec(...escapedArgs, common.mustCall((err, stdout, stderr) => { | ||
| assert.ok( | ||
| stderr.includes('CUSTOM_ABORT_HANDLER_RAN'), | ||
| `Expected custom abort handler marker in stderr, got:\n${stderr}`); | ||
| assert.ok( | ||
| !stderr.includes('Native stack trace'), | ||
| `Expected the custom handler to replace the default dump, got:\n${stderr}`); | ||
|
|
||
| // The child aborts. Whether that surfaces as the SIGABRT signal or as exit | ||
| // code 134 depends on shell wrapping: the `ulimit -c 0 && ...` prefix makes | ||
| // /bin/sh wait on (rather than exec-replace itself with) the node grandchild, | ||
| // so sh reports the aborted grandchild as a normal exit with code 134. | ||
| // common.nodeProcessAborted() accepts both forms. | ||
| assert.ok( | ||
| err && common.nodeProcessAborted(err.code, err.signal), | ||
| `Expected the child to abort, got code=${err?.code} signal=${err?.signal}`); | ||
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.