about summary refs log tree commit diff
path: root/library/panic_unwind/src
AgeCommit message (Collapse)AuthorLines
2025-07-08Win: Use exceptions with empty data for SEH panic exception copiesGeorge Tokmaji-4/+14
instead of a new panic For unwinding with SEH, we currently construct a C++ exception with the panic data. Being a regular C++ exception, it interacts with the C++ exception handling machinery and can be retrieved via `std::current_exception`, which needs to copy the exception. We can't support that, so we panic, which throws another exception, which the C++ runtime tries to copy and store into the exception_ptr, which panics again, which causes the C++ runtime to store a `bad_exception` instance. However, this doesn't work because the panics thrown by the copy function will be dropped without being rethrown, and causes unnecessary log spam in stderr. Fix this by directly throwing an exception without data, which doesn't cause log spam and can be dropped without being rethrown.
2025-06-07intrinsics: use const generic to set atomic orderingRalf Jung-6/+6
2025-05-15deduplicate abort implementationsjoboet-12/+8
Currently, the code for process aborts is duplicated across `panic_abort` and `std`. This PR uses `#[rustc_std_internal_symbol]` to make the `std` implementation available to `panic_abort` via the linker, thereby deduplicating the code.
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-03-06library: Use size_of from the prelude instead of importedThalia Archibald-4/+4
Use `std::mem::{size_of, size_of_val, align_of, align_of_val}` from the prelude instead of importing or qualifying them. These functions were added to all preludes in Rust 1.80.
2025-02-18update `cfg(bootstrap)`Josh Stone-1/+1
2025-02-14panic_unwind: Apply unsafe_op_in_unsafe_fnEric Huss-89/+110
2025-02-10Rollup merge of #136705 - compiler-errors:edition-library, r=jhprattJubilee-9/+9
Some miscellaneous edition-related library tweaks Some library edition tweaks that can be done separately from upgrading the whole standard library to edition 2024 (which is blocked on getting the submodules upgraded, for example)
2025-02-09Mark extern blocks as unsafeMichael Goulet-9/+9
2025-02-08Rustfmtbjorn3-5/+8
2025-02-04Fix unreachable_pub lint for hermit targetThalia Archibald-2/+2
2025-01-20panic_unwind: add `#![warn(unreachable_pub)]`Urgau-26/+27
2025-01-06Rollup merge of #131830 - hoodmane:emscripten-wasm-eh, r=workingjubileeJacob Pratt-1/+2
Add support for wasm exception handling to Emscripten target This is a draft because we need some additional setting for the Emscripten target to select between the old exception handling and the new exception handling. I don't know how to add a setting like that, would appreciate advice from Rust folks. We could maybe choose to use the new exception handling if `Ctarget-feature=+exception-handling` is passed? I tried this but I get errors from llvm so I'm not doing it right.
2025-01-06Add support for wasm exception handling to Emscripten targetHood Chatham-1/+2
Gated behind an unstable `-Z emscripten-wasm-eh` flag
2025-01-03Rollup merge of #133420 - thesummer:rtems-unwind, r=workingjubileeMatthias Krüger-1/+1
Switch rtems target to panic unwind Switch the RTEMS target to `panic_unwind`. Relates to https://github.com/rust-lang/backtrace-rs/pull/682
2025-01-01Rollup merge of #131439 - mu001999-contrib:cleanup/static-mut, r=estebankStuart Cook-2/+0
Remove allowing static_mut_refs lint
2024-11-30Switch rtems target to panic unwindJan Sommer-1/+1
2024-11-29update link to "C++ Exceptions under the hood" blogMartin Kröning-1/+1
The link was introduced in 0ec321f7b541fcbfbf20286beb497e6d9d3352b2. For the old link see https://web.archive.org/web/20170409223244/https://monoinfinito.wordpress.com/series/exception-handling-in-c/. The blog has migrated from WordPress to Blogger in 2021 and to GitHub pages in 2024.
2024-10-21move strict provenance lints to new feature gate, remove old feature gatesRalf Jung-2/+0
2024-10-14Remove allowing static_mut_refs lintmu001999-2/+0
2024-09-26library: Compute `RUST_EXCEPTION_CLASS` from native-endian bytesJubilee Young-1/+1
This makes it appear correctly in hexdumps on both LE and BE platforms.
2024-09-25Use `&raw` in the standard libraryJosh Stone-20/+17
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-24Initial std library support for NuttXHuang Qi-1/+1
Signed-off-by: Huang Qi <huangqi3@xiaomi.com>
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-8/+5
2024-09-20Auto merge of #124895 - obeis:static-mut-hidden-ref, r=compiler-errorsbors-0/+2
Disallow hidden references to mutable static Closes #123060 Tracking: - https://github.com/rust-lang/rust/issues/123758
2024-09-14library: Compute Rust exception class from its string reprJubilee Young-6/+3
2024-09-13Update tests for hidden references to mutable staticObei Sideg-0/+2
2024-09-07Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68bors-6/+0
Bump boostrap compiler to new beta Accidentally left some comments on the update cfgs commit directly xd
2024-09-05update cfgsBoxy-6/+0
2024-09-03Port std library to RTEMSJan Sommer-1/+1
2024-07-30Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68bors-1/+0
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-3/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28step cfg(bootstrap)Mark Rousskov-1/+0
2024-07-23Rollup merge of #125834 - ↵Matthias Krüger-0/+6
workingjubilee:weaken-thir-unsafeck-for-addr-of-static-mut, r=compiler-errors treat `&raw (const|mut) UNSAFE_STATIC` implied deref as safe Fixes rust-lang/rust#125833 As reported in that and related issues, `static mut STATIC_MUT: T` is very often used in embedded code, and is in many ways equivalent to `static STATIC_CELL: SyncUnsafeCell<T>`. The Rust expression of `&raw mut STATIC_MUT` and `SyncUnsafeCell::get(&STATIC_CELL)` are approximately equal, and both evaluate to `*mut T`. The library function is safe because it has *declared itself* to be safe. However, the raw ref operator is unsafe because all uses of `static mut` are considered unsafe, even though the static's value is not used by this expression (unlike, for example, `&STATIC_MUT`). We can fix this unnatural difference by simply adding the proper exclusion for the safety check inside the THIR unsafeck, so that we do not declare it unsafe if it is not. While the primary concern here is `static mut`, this change is made for all instances of an "unsafe static", which includes a static declared inside `extern "abi" {}`. Hypothetically, we could go as far as generalizing this to all instances of `&raw (const|mut) *ptr`, but today we do not, as we have not actually considered the range of possible expressions that use a similar encoding. We do not even extend this to thread-local equivalents, because they have less clear semantics.
2024-07-22library: vary unsafety in bootstrapping for SEHJubilee Young-0/+6
2024-07-01Use the native unwind function in miri where possiblebjorn3-21/+13
2024-06-20Auto merge of #126736 - matthiaskrgr:rollup-rb20oe3, r=matthiaskrgrbors-0/+1
Rollup of 7 pull requests Successful merges: - #126380 (Add std Xtensa targets support) - #126636 (Resolve Clippy `f16` and `f128` `unimplemented!`/`FIXME`s ) - #126659 (More status-quo tests for the `#[coverage(..)]` attribute) - #126711 (Make Option::as_[mut_]slice const) - #126717 (Clean up some comments near `use` declarations) - #126719 (Fix assertion failure for some `Expect` diagnostics.) - #126730 (Add opaque type corner case test) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-20Add blank lines after module-level `//!` comments.Nicholas Nethercote-0/+1
Most modules have such a blank line, but some don't. Inserting the blank line makes it clearer that the `//!` comments are describing the entire module, rather than the `use` declaration(s) that immediately follows.
2024-06-19Stabilise c_unwindGary Guo-1/+1
2024-04-14Replace libc::c_int with core::ffi::c_intChris Denton-1/+1
And remove the libc crate when it isn't needed
2024-04-11Refactor `panic_unwind/seh.rs` pointer use; x86 now conforms to ↵niluxv-41/+73
strict-provenance
2024-03-19SeqCst->Relaxed in panic_unwind/emcc.Mara Bos-1/+1
SeqCst is unnecessary here.
2024-03-11Rollup merge of #121438 - coolreader18:wasm32-panic-unwind, r=cuviperJubilee-2/+2
std support for wasm32 panic=unwind Tracking issue: #118168 This adds std support for `-Cpanic=unwind` on wasm, and with it slightly more fleshed out rustc support. Now, the stable default is still panic=abort without exception-handling, but if you `-Zbuild-std` with `RUSTFLAGS=-Cpanic=unwind`, you get wasm exception-handling try/catch blocks in the binary: ```rust #[no_mangle] pub fn foo_bar(x: bool) -> *mut u8 { let s = Box::<str>::from("hello"); maybe_panic(x); Box::into_raw(s).cast() } #[inline(never)] #[no_mangle] fn maybe_panic(x: bool) { if x { panic!("AAAAA"); } } ``` ```wat ;; snip... (try $label$5 (do (call $maybe_panic (local.get $0) ) (br $label$1) ) (catch_all (global.set $__stack_pointer (local.get $1) ) (call $__rust_dealloc (local.get $2) (i32.const 5) (i32.const 1) ) (rethrow $label$5) ) ) ;; snip... ```
2024-02-26miri: rename miri_start_panic → miri_start_unwindRalf Jung-3/+3
2024-02-23Get rid of some `#[allow(static_mut_refs)]`Pavel Grigorenko-22/+17
2024-02-22Use Itanium ABI for thrown exceptionsNoa-40/+2
2024-02-22Unconditionally pass -wasm-enable-ehNoa-6/+1
2024-02-22std support for wasm32 panic=unwindNoa-1/+44
2024-02-18Improve wording of static_mut_refObei Sideg-4/+6
Rename `static_mut_ref` lint to `static_mut_refs`.