-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows
Description
A comment in the std claims that unwinding past lang_start
is UB:
Lines 136 to 145 in 6874f4e
// Guard against the code called by this function from unwinding outside of the Rust-controlled | |
// code, which is UB. This is a requirement imposed by a combination of how the | |
// `#[lang="start"]` attribute is implemented as well as by the implementation of the panicking | |
// mechanism itself. | |
// | |
// There are a couple of instances where unwinding can begin. First is inside of the | |
// `rt::init`, `rt::cleanup` and similar functions controlled by bstd. In those instances a | |
// panic is a std implementation bug. A quite likely one too, as there isn't any way to | |
// prevent std from accidentally introducing a panic to these functions. Another is from | |
// user code from `main` or, more nefariously, as described in e.g. issue #86030. |
This is surprising because C++ panics escaping main is well defined to terminate (and will trigger an attached debugger, which is useful).
cc @Amanieu, who questioned this assertion.
Metadata
Metadata
Assignees
Labels
A-runtimeArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflowsArea: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows