Skip to content

std: Improve the documentation for crash and other exit API - #166190

Open
tgross35 wants to merge 3 commits into
rust-lang:mainfrom
tgross35:exit-docs
Open

tgross35 wants to merge 3 commits into
rust-lang:mainfrom
tgross35:exit-docs

Conversation

@tgross35

@tgross35 tgross35 commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

View all comments

In std::process, add a comparison of all the different forms of exiting we have. Also link abort and crash to this new documentation, hopefully nudging away users who don't actually need their behavior.

The first two commits also update the run-make exit test to cover forms that weren't yet covered (look at individual commits so the diff doesn't look as messy with the rename).

@rustbot rustbot added A-process Area: `std::process` (note: `std::env` is A-env) A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 19, 2026
@tgross35

Copy link
Copy Markdown
Member Author

@bors try jobs=test-x86_64-msvc*,test-various,test-arm-android,test-aarch64-apple-*

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 19, 2026
[WIP] panic abort exit crash oh my


try-job: test-x86_64-msvc*
try-job: test-various
try-job: test-arm-android
try-job: test-aarch64-apple-*
@rust-log-analyzer

This comment has been minimized.

@tgross35

Copy link
Copy Markdown
Member Author

@bors try cancel

@rust-bors

rust-bors Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Try build cancelled. Cancelled workflows:

Hint: if you want to run another try build, you do not need to manually cancel the previous one. Just run @bors try and bors will cancel the previous build automatically.

@tgross35

Copy link
Copy Markdown
Member Author

@bors try jobs=test-x86_64-msvc*,test-various,test-arm-android,test-aarch64-apple-*

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Nov 19, 2026
[WIP] panic abort exit crash oh my


try-job: test-x86_64-msvc*
try-job: test-various
try-job: test-arm-android
try-job: test-aarch64-apple-*
@tgross35 tgross35 changed the title [WIP] panic abort exit crash oh my std: Improve the documentation for crash and other exit API Nov 19, 2026
@tgross35 tgross35 removed the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Nov 19, 2026
@tgross35
tgross35 marked this pull request as ready for review November 19, 2026 10:54
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 19, 2026
@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 19, 2026
@rustbot

rustbot commented Nov 19, 2026

Copy link
Copy Markdown
Collaborator

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 79 candidates
  • Random selection from 21 candidates

@tgross35

Copy link
Copy Markdown
Member Author

r? libs

@the8472 @RalfJung does this address your concerns at #164731 (comment) and #164731 (comment)?

@RalfJung

Copy link
Copy Markdown
Member

The first link does not work for me so I am not sure which concerns you mean.
The 2nd one s about naming which yeah is resolved by calling it crash.

@tgross35

Copy link
Copy Markdown
Member Author

Huh, they both work for me. Specific bits I'm referring to:

We should at least look at which flavors of aborting/crashing we have/may have in the future. And if the names distinguish them well enough

  • crash
  • abort
  • panic
  • panic_nounwind
  • (internally) rtabort (print + abort)
  • exit
  • ???

And:

I associate "crash" with something unsafe so the docs should emphasize that this is a safe form of crashing, but that doesn't have to appear in the name.

Comment thread library/core/src/process.rs Outdated
/// process], unless absolute minimum overhead is required.
///
/// While this function provides an abrupt exit, note that it is still a safe
/// form of crashing—unlike some uses of the terms "crash" or "trap".

@RalfJung RalfJung Nov 19, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/// form of crashing—unlike some uses of the terms "crash" or "trap".
/// form of crashing—unlike, for example, a segfault caused by a null pointer dereference.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Applied

Comment thread library/core/src/process.rs Outdated

@RalfJung RalfJung Nov 19, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
/// Terminates the process in a violent but safe fashion.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Applied

//! Use these guidelines to pick which to use:
//!
//! * Use `exit` or return `ExitCode` for exiting as part of normal program
//! behavior. These exit with no additional message, just the provided code.

@RalfJung RalfJung Nov 19, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

#165125 makes exit do basically no cleanup at all, doesn't it?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I believe that's correct. I think it should be fine to have "partial" in the table then change it to "no" in that PR (assuming this may merge first).

Comment thread library/std/src/process.rs Outdated
//! | [`panic!`] | 101 | 101 | None | Yes |
//! | [`exit`] | User-provided | User-provided | None | Partial |
//! | [`abort`] | None | `STATUS_STACK_BUFFER_OVERRUN` | `SIGABRT` | No |
//! | [`crash`] | None | Unspecified | Unspecified (typically `SIGTRAP` or `SIGILLL`) | No |

@joboet joboet Nov 19, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
//! | [`crash`] | None | Unspecified | Unspecified (typically `SIGTRAP` or `SIGILLL`) | No |
//! | [`crash`] | None | Unspecified | Unspecified (typically `SIGTRAP` or `SIGILL`) | No |

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Corrected to SIGILLLLLLLLL

Comment thread library/std/src/process.rs Outdated
//! | Return [`ExitCode`] or a `Result` from `main` | User-provided | User-provided | None | Yes |
//! | [`panic!`] | 101 | 101 | None | Yes |
//! | [`exit`] | User-provided | User-provided | None | Partial |
//! | [`abort`] | None | `STATUS_STACK_BUFFER_OVERRUN` | `SIGABRT` | No |

@joboet joboet Nov 19, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd perhaps even link to https://devblogs.microsoft.com/oldnewthing/20190108-00/?p=100655/, I found this status to be confusing...

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah that's just not a good name. I added a footnote clarifying a bit and linking to docs for __fastfail, which is where this comes from.

@rust-log-analyzer

This comment has been minimized.

In `std::process`, add a comparison of all the different forms of
exiting we have. Also link `abort` and `crash` to this new
documentation, hopefully nudging away users who don't actually need
their behavior.
@rust-bors

rust-bors Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 98aa3a5 (98aa3a5e8a08b68a64300249c919dc4578072dc9)
Base parent: b0b6006 (b0b600668bb9b4a897e2299b0a44289d42276545)

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-process Area: `std::process` (note: `std::env` is A-env) A-run-make Area: port run-make Makefiles to rmake.rs S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants