about summary refs log tree commit diff
path: root/library/std/src/panicking.rs
AgeCommit message (Collapse)AuthorLines
2025-09-21Change the cfg to a dashBen Kimock-10/+10
2025-09-21Add panic=immediate-abortBen Kimock-14/+12
2025-09-02improve process::abort rendering in Miri backtracesRalf Jung-2/+2
2025-08-07Rollup merge of #144903 - Kivooeo:panic_handler-is-not-begin, r=m-ou-seTrevor Gross-1/+1
Rename `begin_panic_handler` to `panic_handler` Part of https://github.com/rust-lang/rust/issues/116005
2025-08-06Print thread ID in panic message if thread name is unknownTrevor Gross-1/+2
`panic!` does not print any identifying information for threads that are unnamed. However, in many cases, the thread ID can be determined. This changes the panic message from something like this: thread '<unnamed>' panicked at src/main.rs:3:5: explicit panic To something like this: thread '<unnamed>' (0xff9bf) panicked at src/main.rs:3:5: explicit panic Stack overflow messages are updated as well. This change applies to both named and unnamed threads. The ID printed is the OS integer thread ID rather than the Rust thread ID, which should also be what debuggers print.
2025-08-05Rollup merge of #144852 - Kivooeo:rename-panic, r=m-ou-seSamuel Tardieu-1/+1
Rename `rust_panic_without_hook` to `resume_unwind` part of https://github.com/rust-lang/rust/issues/116005 r? libs
2025-08-04remove begin prefixKivooeo-1/+1
2025-08-03remove rust_ prefixesKivooeo-6/+6
2025-08-03rename rust_panic_without_hookKivooeo-1/+1
2025-05-24rename internal panicking::try to catch_unwindRalf Jung-4/+4
2025-04-27use generic Atomic type where possibleChristopher Durham-4/+4
in core/alloc/std only for now, and ignoring test files Co-authored-by: Pavel Grigorenko <GrigorenkoPV@ya.ru>
2025-04-09update cfgsBoxy-2/+2
2025-03-17Mark imports of #[rustc_std_internal_symbol] items with this attributebjorn3-0/+2
This ensures that they will be correctly mangled in a future commit.
2025-02-09Mark extern blocks as unsafeMichael Goulet-2/+2
2025-01-14std: lazily allocate the main thread handlejoboet-18/+21
Thereby, we also allow accessing thread::current before main: as the runtime no longer tries to install its own handle, this will no longer trigger an abort. Rather, the name returned from name will only be "main" after the runtime initialization code has run, but I think that is acceptable. This new approach also requires some changes to the signal handling code, as calling `thread::current` would now allocate when called on the main thread, which is not acceptable. I fixed this by adding a new function (`with_current_name`) that performs all the naming logic without allocation or without initializing the thread ID (which could allocate on some platforms).
2025-01-01Try to write the panic message with a single `write_all` callJohn Kåre Alsaker-1/+17
2024-12-23Use `#[derive(Default)]` instead of manually implementing itEsteban Küber-7/+2
2024-12-05Added struct `fmt::FormattingOptions`Elias Holzmann-1/+1
This allows to build custom `std::Formatter`s at runtime. Also added some related enums and two related methods on `std::Formatter`.
2024-11-28Share inline(never) generics across cratesMark Rousskov-0/+16
This reduces code sizes and better respects programmer intent when marking inline(never). Previously such a marking was essentially ignored for generic functions, as we'd still inline them in remote crates.
2024-09-26Rollup merge of #130846 - ChrisDenton:revert-break, r=NoratriebJubilee-17/+1
Revert Break into the debugger on panic (129019) This was talked about a bit at a recent libs meeting. While I think experimenting with this is worthwhile, I am nervous about this new behaviour reaching stable. We've already reverted on one tier 1 platform (Linux, https://github.com/rust-lang/rust/pull/130810) which means we have differing semantics on different tier 1 platforms. Also the fact it triggers even when `catch_unwind` is used to catch the panic means it can be very noisy in some projects. At the very least I think it could use some more discussion before being instantly stable. I think this could maybe be re-landed with an environment variable to control/override the behaviour. But that part would likely need a libs-api decision. cc ````@workingjubilee```` ````@kromych````
2024-09-25Use `&raw` in the standard libraryJosh Stone-1/+1
Since the stabilization in #127679 has reached stage0, 1.82-beta, we can start using `&raw` freely, and even the soft-deprecated `ptr::addr_of!` and `ptr::addr_of_mut!` can stop allowing the unstable feature. I intentionally did not change any documentation or tests, but the rest of those macro uses are all now using `&raw const` or `&raw mut` in the standard library.
2024-09-25Revert Break into the debugger on panic (129019)Chris Denton-17/+1
2024-09-08Auto merge of #129019 - kromych:master, r=workingjubileebors-1/+17
Break into the debugger (if attached) on panics (Windows, Linux, macOS, FreeBSD) The developer experience for panics is to provide the backtrace and exit the program. When running under debugger, that might be improved by breaking into the debugger once the code panics thus enabling the developer to examine the program state at the exact time when the code panicked. Let the developer catch the panic in the debugger if it is attached. If the debugger is not attached, nothing changes. Providing this feature inside the standard library facilitates better debugging experience. Validated under Windows, Linux, macOS 14.6, and FreeBSD 13.3..14.1.
2024-09-05Break into the debugger (if attached) on panics (Windows, macOS, Linux, FreeBSD)kromych-1/+17
The developer experience for panics is to provide the backtrace and exit the program. When running under debugger, that might be improved by breaking into the debugger once the code panics thus enabling the developer to examine the program state at the exact time when the code panicked. Let the developer catch the panic in the debugger if it is attached. If the debugger is not attached, nothing changes. Providing this feature inside the standard library facilitates better debugging experience. Validated under Windows, Linux, macOS 14.6, and FreeBSD 13.3..14.1.
2024-09-02Auto merge of #129063 - the8472:cold-opt-size, r=Amanieubors-2/+6
Apply size optimizations to panic machinery and some cold functions * std dependencies gimli and addr2line are now built with opt-level=s * various panic-related methods and `#[cold]` methods are now marked `#[optimize(size)]` Panics should be cold enough that it doesn't make sense to optimize them for speed. The only tradeoff here is if someone does a lot of backtrace captures (without panics) and printing then the opt-level change might impact their perf. Seems to be the first use of the optimize attribute. Tracking issue #54882
2024-08-24panicking: improve hint for Miri's RUST_BACKTRACE behaviorRalf Jung-1/+1
2024-08-14apply #[optimize(size)] to #[cold] ones and part of the panick machineryThe 8472-2/+6
2024-07-29Reformat `use` declarations.Nicholas Nethercote-12/+9
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-12fix interleaved panic outputjyn-2/+6
previously, we only held a lock for printing the backtrace itself. since all threads were printing to the same file descriptor, that meant random output in the default panic hook would be interleaved with the backtrace. now, we hold the lock for the full duration of the hook, and the output is ordered.
2024-06-17Add PanicMessage type for PanicInfo::message().Mara Bos-5/+8
2024-06-16std: move `sys_common::backtrace` to `sys`joboet-3/+3
2024-06-11Formatting.Mara Bos-1/+3
2024-06-11Fix display of panic message in recursive panic.Mara Bos-9/+6
2024-06-11Rename std::panic::PanicInfo to PanicHookInfo.Mara Bos-10/+15
2024-06-11Reorder body of begin_panic for consistency.Mara Bos-17/+11
In the other functions, we put the struct and impl blocks first, such that the return expression can be at the end of the body as usual.
2024-06-11Impl Display for PanicPayload to simplify things.Mara Bos-9/+28
2024-06-11Use unnamed lifetimes for [..]Payload impl blocks.Mara Bos-7/+3
2024-06-11Move downcasting panic payload to str to a function.Mara Bos-7/+11
2024-06-11Remove std::panic::PanicInfo::internal_constructor+set_payload.Mara Bos-9/+4
We can just set the payload immediately in the constructor, and the constructor does not need to be public.
2024-06-11Split core's PanicInfo and std's PanicInfo.Mara Bos-21/+16
2024-04-18when suggesting RUST_BACKTRACE=1, add a special note for Miri's env var ↵Ralf Jung-0/+7
isolation
2024-04-11Rollup merge of #122882 - Zoxc:panic-output-panic, r=AmanieuMatthias Krüger-4/+4
Avoid a panic in `set_output_capture` in the default panic handler This avoid a panic in the default panic handler by not using `set_output_capture` as `OUTPUT_CAPTURE.with` may panic once `OUTPUT_CAPTURE` is dropped. A new non-panicking `try_set_output_capture` variant of `set_output_capture` is added for use in the default panic handler.
2024-03-31std: move `thread::current` TLS variable out of `thread_info`joboet-2/+1
2024-03-24panic-in-panic-hook: formatting a message that's just a string is risk-freeRalf Jung-5/+9
2024-03-23Rollup merge of #122930 - RalfJung:panic-in-panic-fmt, r=AmanieuMatthias Krüger-1/+7
add panic location to 'panicked while processing panic' Fixes https://github.com/rust-lang/rust/issues/97181 r? `@Amanieu`
2024-03-23add panic location to 'panicked while processing panic'Ralf Jung-1/+7
2024-03-22Avoid a panic in `set_output_capture` in the default panic handlerJohn Kåre Alsaker-4/+4
2024-03-19SeqCst->Relaxed for FIRST_PANIC.Mara Bos-1/+1
Relaxed is enough to make sure this `swap` results in `true` only once.
2024-02-26rename 'try' intrinsic to 'catch_unwind'Ralf Jung-4/+4
2024-02-24library: use `addr_of!`Pavel Grigorenko-1/+1