Skip to content
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,lib: make ^C print a JS stack trace #29207

Closed
wants to merge 1 commit into from

Conversation

legendecas
Copy link
Member

@legendecas legendecas commented Aug 19, 2019

If terminating the process with ctrl-c / SIGINT, prints a JS stack trace leading up to the currently executing code.

The feature would be enabled under option --trace-sigint.

Conditions of no stacktrace on sigint:

  1. has (an) active sigint listener(s);
  2. main thread is idle (i.e. uv polling), a message instead of stacktrace would be printed.

Related: #24937

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the c++ Issues and PRs that require attention from people who are familiar with C++. label Aug 19, 2019
@mscdex
Copy link
Contributor

mscdex commented Aug 19, 2019

Maybe we should only print a stack trace if stdin is a TTY (especially if it's meant to only happen when pressing ctrl-c)?

@devsnek devsnek added the wip Issues and PRs that are still a work in progress. label Aug 19, 2019
lib/internal/main/run_main_module.js Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments but nice work!

src/node_watchdog.cc Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
@legendecas legendecas force-pushed the issue-24937 branch 3 times, most recently from 503aca6 to f175639 Compare August 24, 2019 13:14
@legendecas legendecas changed the title cli: make ^C print a JS stack trace report: make ^C print a JS stack trace Aug 24, 2019
Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

report: is the subsystem for the node-report feature, i.e. node --experimental-report … this touches a related topic, but I think it might be confusing to name it that way

src/node_watchdog.h Outdated Show resolved Hide resolved
src/node_watchdog.h Outdated Show resolved Hide resolved
src/node_watchdog.cc Outdated Show resolved Hide resolved
lib/internal/main/run_main_module.js Outdated Show resolved Hide resolved
@legendecas
Copy link
Member Author

report: is the subsystem for the node-report feature, i.e. node --experimental-report … this touches a related topic, but I think it might be confusing to name it that way

Yes, this work doesn't touch report specifically in codebase. Yet I don't find a more proper subsystem here https://github.com/nodejs/core-validate-commit/blob/master/lib/rules/subsystem.js . Since both src and lib are touched in this work, neither of those one might be appropriate IMO.

@addaleax
Copy link
Member

@legendecas You can also use src,lib: .... 🙂 Honestly, I don’t have a better idea than that either.

@legendecas legendecas changed the title report: make ^C print a JS stack trace src,lib: make ^C print a JS stack trace Aug 24, 2019
@legendecas legendecas force-pushed the issue-24937 branch 2 times, most recently from 3797e8e to 822e56a Compare August 24, 2019 14:13
lib/internal/bootstrap/pre_execution.js Outdated Show resolved Hide resolved
@legendecas legendecas force-pushed the issue-24937 branch 2 times, most recently from 124c8c3 to b7ccab2 Compare August 24, 2019 16:44
@legendecas
Copy link
Member Author

I think this PR is out of WIP, ready to be reviewed thoroughly :)

@addaleax addaleax removed the wip Issues and PRs that are still a work in progress. label Aug 24, 2019
src/node_watchdog.h Outdated Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

@addaleax
Copy link
Member

@addaleax
Copy link
Member

@legendecas Looks like there are still issues with the postmortem tests…

@legendecas
Copy link
Member Author

@legendecas Looks like there are still issues with the postmortem tests…

I'll try to fix it :P

@Trott Trott dismissed Fishrock123’s stale review January 12, 2020 17:39

Concerns appear to have been addressed. Unresponsive to pings. Dismissing.

@Fishrock123
Copy link
Contributor

I will attempt to take a look but I am in transit today. If I don’t see it by mid Monday just go ahead.

@Fishrock123 Fishrock123 removed their request for review January 14, 2020 19:49
@Fishrock123
Copy link
Contributor

Fishrock123 commented Jan 14, 2020

I don't have any substantive opinions for this.

@legendecas
Copy link
Member Author

Since there are no objections anymore and multiple approves, I'd tag this as author-ready.

@legendecas legendecas added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 17, 2020
If terminating the process with ctrl-c / SIGINT, prints a JS stacktrace
leading up to the currently executing code.

The feature would be enabled under option --trace-sigint.

Conditions of no stacktrace on sigint:

- has (an) active sigint listener(s);
- main thread is idle (i.e. uv polling), a message instead of stacktrace
  would be printed.
@legendecas legendecas removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 25, 2020
@legendecas
Copy link
Member Author

Rebased to resolve conflicts.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot

This comment has been minimized.

@nodejs-github-bot
Copy link
Collaborator

@legendecas legendecas added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jan 26, 2020
legendecas added a commit that referenced this pull request Jan 28, 2020
If terminating the process with ctrl-c / SIGINT, prints a JS stacktrace
leading up to the currently executing code.

The feature would be enabled under option `--trace-sigint`.

Conditions of no stacktrace on sigint:

- has (an) active sigint listener(s);
- main thread is idle (i.e. uv polling), a message instead of stacktrace
  would be printed.

PR-URL: #29207
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Christopher Hiller <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@legendecas
Copy link
Member Author

Landed with 7b7e7bd 🎉

@legendecas legendecas closed this Jan 28, 2020
@legendecas legendecas deleted the issue-24937 branch January 28, 2020 05:54
@ruyadorno
Copy link
Member

ruyadorno commented Jan 28, 2020

/cc @nodejs/tooling this landed 🎉 yay! we might want to talk about it in the next tooling WG meeting

codebytere pushed a commit that referenced this pull request Feb 17, 2020
If terminating the process with ctrl-c / SIGINT, prints a JS stacktrace
leading up to the currently executing code.

The feature would be enabled under option `--trace-sigint`.

Conditions of no stacktrace on sigint:

- has (an) active sigint listener(s);
- main thread is idle (i.e. uv polling), a message instead of stacktrace
  would be printed.

PR-URL: #29207
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Christopher Hiller <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@codebytere codebytere mentioned this pull request Feb 17, 2020
@targos targos removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 25, 2020
targos pushed a commit to targos/node that referenced this pull request Apr 25, 2020
If terminating the process with ctrl-c / SIGINT, prints a JS stacktrace
leading up to the currently executing code.

The feature would be enabled under option `--trace-sigint`.

Conditions of no stacktrace on sigint:

- has (an) active sigint listener(s);
- main thread is idle (i.e. uv polling), a message instead of stacktrace
  would be printed.

PR-URL: nodejs#29207
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Christopher Hiller <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
targos pushed a commit that referenced this pull request Apr 28, 2020
If terminating the process with ctrl-c / SIGINT, prints a JS stacktrace
leading up to the currently executing code.

The feature would be enabled under option `--trace-sigint`.

Conditions of no stacktrace on sigint:

- has (an) active sigint listener(s);
- main thread is idle (i.e. uv polling), a message instead of stacktrace
  would be printed.

PR-URL: #29207
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: Christopher Hiller <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. semver-minor PRs that contain new features and should be released in the next minor version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.