summary refs log tree commit diff
path: root/library/std/src/panic.rs
AgeCommit message (Collapse)AuthorLines
2025-02-13std: Apply dependency_on_unit_never_type_fallbackEric Huss-1/+3
This generates a warning of irrefutable patterns. I decided to slightly tweak the example so the closure returns unit, since the intent wasn't to show the weird behavior of returning `!`.
2025-01-26Move std::panic unit tests to integration testsbjorn3-3/+0
2024-09-29Auto merge of #128321 - BatmanAoD:catch-unwind-doc-update, r=Mark-Simulacrumbors-24/+34
Update `catch_unwind` doc comments for `c_unwind` Updates `catch_unwind` doc comments to indicate that catching a foreign exception _will no longer_ be UB. Instead, there are two possible behaviors, though it is not specified which one an implementation will choose. Nominated for t-lang to confirm that they are okay with making such a promise based on t-opsem FCP, or whether they would like to be included in the FCP. Related: https://github.com/rust-lang/rust/issues/74990, https://github.com/rust-lang/rust/issues/115285, https://github.com/rust-lang/reference/pull/1226
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-2/+2
2024-09-15update docs for `catch_unwind` & related funcsKyle J Strand-24/+34
Documentation comments for `catch_unwind` and `thread::join` to indicate new behavioral guarantee when catching a foreign exception.
2024-09-14add std::panic::abort_unwindChristopher Durham-0/+3
2024-08-12std: do not overwrite style in `get_backtrace_style`joboet-11/+15
If another thread calls `set_backtrace_style` while a `get_backtrace_style` is reading the environment variables, `get_backtrace_style` will overwrite the value. Use an atomic CAS to avoid this.
2024-08-03chore: refactor backtrace style in panicKonippi-19/+10
2024-07-30Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68bors-1/+1
Bump bootstrap compiler to new beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-07-29Reformat `use` declarations.Nicholas Nethercote-10/+5
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28Update CURRENT_RUSTC_VERSIONMark Rousskov-1/+1
2024-07-26Fix doc nitsJohn Arundel-3/+3
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-06-12Use payload_as_str instead of two downcasts.Mara Bos-4/+1
2024-06-11Bump deprecation of std's PanicInfo alias to 1.82.0.Mara Bos-1/+1
2024-06-11Add PanicHookInfo::payload_as_str().Mara Bos-0/+39
2024-06-11Add note on panic payload type.Mara Bos-0/+7
2024-06-11Downcast panic payload to String too in example.Mara Bos-0/+2
2024-06-11Move deprecation of std::panic::PanicInfo to 1.80.0.Mara Bos-1/+1
2024-06-11Rename std::panic::PanicInfo to PanicHookInfo.Mara Bos-13/+18
2024-06-11Mark some PanicInfo methods as #[inline] for consistency.Mara Bos-0/+3
2024-06-11Remove std::panic::PanicInfo::internal_constructor+set_payload.Mara Bos-12/+3
We can just set the payload immediately in the constructor, and the constructor does not need to be public.
2024-06-11Fix doc link.Mara Bos-3/+2
2024-06-11Document difference between core and std's PanicInfo.Mara Bos-2/+9
2024-06-11Split core's PanicInfo and std's PanicInfo.Mara Bos-1/+152
2024-03-31catch_panic: warn about panicking payload dropRalf Jung-0/+3
2024-02-28Implement unwind safety for CondvarJonathan Johnson-1/+5
Closes #118009 This commit adds unwind safety to Condvar. Previously, only select platforms implemented unwind safety through auto traits. Known by this committer: Linux was unwind safe, but Mac and Windows are not before this change.
2024-01-31Store SHOULD_CAPTURE as AtomicU8GnomedDev-6/+6
2023-12-09merge core_panic feature into panic_internalsRalf Jung-1/+1
2023-05-15Shorten lifetime of even more panic temporariesDavid Tolnay-2/+2
2023-05-14Shorten lifetime of panic temporaries in panic_fmt caseDavid Tolnay-1/+3
2023-03-17reviewGus Caplan-1/+1
2023-03-17move default backtrace setting to sysGus Caplan-2/+1
2022-12-28Clarify catch_unwind docs about panic hooksAlbert Larsan-0/+3
Makes it clear from catch_unwind docs that the panic hook will be called before the panic is caught.
2022-09-14Adding backtrace off option for fuchsia targetsAndrew Pollack-17/+16
2022-07-08Support unstable moves via stable in unstable itemsJane Lusby-1/+1
2022-02-02Configure panic hook backtrace behaviorMark Rousskov-0/+114
2022-01-07Implement panic::update_hookBadel2-0/+3
2021-10-19Deduplicate panic_fmtGary Guo-1/+1
std's begin_panic_fmt and core's panic_fmt are duplicates. Merge them to declutter code and remove a lang item.
2021-09-15Allow `panic!("{}", computed_str)` in const fn.Gary Guo-1/+5
2021-07-30Move UnwindSafe, RefUnwindSafe, AssertUnwindSafe to coreDavid Tolnay-309/+4
2021-07-30Auto merge of #87445 - amalik18:issue-83584-fix, r=kennytmbors-2/+2
Fix may not to appropriate might not or must not I went through and changed occurrences of `may not` to be more explicit with `might not` and `must not`.
2021-07-29Fix may not to appropriate might not or must notAli Malik-2/+2
2021-07-28Add new const_format_args!() macro and use it in panics.Mara Bos-2/+2
2021-06-29Use diagnostic items to check for Send, UnwindSafe and RefUnwindSafe traitsRoxane Fruytier-2/+2
2021-06-29Remove lang items Send, UnwindSafe and RefUnwindSafeRoxane Fruytier-2/+2
2021-06-28Update to new bootstrap compilerMark Rousskov-2/+2
2021-05-27Add #[track_caller] to panic_anyAlex Veber-0/+1
2021-05-15Auto merge of #81858 - ijackson:fork-no-unwind, r=m-ou-sebors-0/+36
Do not allocate or unwind after fork ### Objective scenarios * Make (simple) panics safe in `Command::pre_exec_hook`, including most `panic!` calls, `Option::unwrap`, and array bounds check failures. * Make it possible to `libc::fork` and then safely panic in the child (needed for the above, but this requirement means exposing the new raw hook API which the `Command` implementation needs). * In singlethreaded programs, where panic in `pre_exec_hook` is already memory-safe, prevent the double-unwinding malfunction #79740. I think we want to make panic after fork safe even though the post-fork child environment is only experienced by users of `unsafe`, beause the subset of Rust in which any panic is UB is really far too hazardous and unnatural. #### Approach * Provide a way for a program to, at runtime, switch to having panics abort. This makes it possible to panic without making *any* heap allocations, which is needed because on some platforms malloc is UB in a child forked from a multithreaded program (see https://github.com/rust-lang/rust/pull/80263#issuecomment-774272370, and maybe also the SuS [spec](https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html)). * Make that change in the child spawned by `Command`. * Document the rules comprehensively enough that a programmer has a fighting chance of writing correct code. * Test that this all works as expected (and in particular, that there aren't any heap allocations we missed) Fixes #79740 #### Rejected (or previously attempted) approaches * Change the panic machinery to be able to unwind without allocating, at least when the payload and message are both `'static`. This seems like it would be even more subtle. Also that is a potentially-hot path which I don't want to mess with. * Change the existing panic hook mechanism to not convert the message to a `String` before calling the hook. This would be a surprising change for existing code and would not be detected by the type system. * Provide a `raw_panic_hook` function to intercept panics in a way that doesn't allocate. (That was an earlier version of this MR.) ### History This MR could be considered a v2 of #80263. Thanks to everyone who commented there. In particular, thanks to `@m-ou-se,` `@Mark-Simulacrum` and `@hyd-dev.` (Tagging you since I think you might be interested in this new MR.) Compared to #80263, this MR has very substantial changes and additions. Additionally, I have recently (2021-04-20) completely revised this series following very helpful comments from `@m-ou-se.` r? `@m-ou-se`
2021-05-11use the correct attributes and add helper functionRoxane-2/+2
2021-05-07std panicking: Provide panic::always_abortIan Jackson-0/+36
We must change the atomic read on panic entry to `Acquire`, to pick up a possible an `always_panic` on another thread. We add `count` to the names of panic_count::get and ::is_zaero, because now there is another reason why panic ought to maybe abort. Renaming these ensures that we have checked every call site to ensure that they don't need further adjustment. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk> Co-authored-by: Mara Bos <m-ou.se@m-ou.se>