Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
25ab022
move `tests/ui/resolve/suggest*` to `tests/ui/resolve/suggestions/`
xizheyin Jun 29, 2025
000f038
Add ui test resolve/false-self-in-macro-issue-143134.rs
xizheyin Jun 29, 2025
236b392
Return early when `self` resolve failure because of `let self = ...`
xizheyin Jun 29, 2025
1a1b52a
clippy fix: indentation
hkBst Jul 4, 2025
995eeeb
Don't call predicates_of on a dummy obligation cause's body id
compiler-errors Jul 5, 2025
b63f920
More carefully consider span context when suggesting remove &mut
compiler-errors Jul 6, 2025
b4e68e2
Respect endianness correctly in CheckEnums test suite
1c3t3a Jul 2, 2025
e2891c0
configure.py: Write last key in each section
lambdageek Jul 7, 2025
b6d2130
Add docstring
lambdageek Jul 7, 2025
0455577
fix: correct parameter names in LLVMRustBuildMinNum and LLVMRustBuild…
dillona Jul 8, 2025
3ba8e33
Rewrite for clarity
lambdageek Jul 8, 2025
c4bf37d
Always inline InterpCx::layout_of after perf regression
Stypox Jul 2, 2025
07143af
Replace TRACING_ENABLED with enter_trace_span()
Stypox Jul 5, 2025
3cacaa7
Add inline(always) to Machine::enter_trace_span
Stypox Jul 6, 2025
e8c8330
Make enter_trace_span take a closure for better optimization
Stypox Jul 6, 2025
e5f7d4d
Implement enter_trace_span() in MiriMachine
Stypox Jul 8, 2025
fab9c64
Add triagebot stdarch mention ping
Kobzol Jul 8, 2025
7c8a6d9
Spelling
lambdageek Jul 8, 2025
96cdbb9
Win: Use exceptions with empty data for SEH panic exception copies
Fulgen301 Jul 8, 2025
87e7539
Disable docs for `compiler-builtins` and `sysroot`
cuviper Jul 8, 2025
c8b2c78
Rollup merge of #143177 - xizheyin:143134, r=lcnr
jhpratt Jul 9, 2025
f205b45
Rollup merge of #143339 - 1c3t3a:issue-143332, r=RalfJung
jhpratt Jul 9, 2025
6d9f589
Rollup merge of #143426 - hkBst:clippy-fix-indent-1, r=jhpratt
jhpratt Jul 9, 2025
3b0f873
Rollup merge of #143499 - compiler-errors:predicates-of-crate, r=davi…
jhpratt Jul 9, 2025
8222dd3
Rollup merge of #143520 - Stypox:enter_trace_span-closure, r=RalfJung
jhpratt Jul 9, 2025
95b0f9e
Rollup merge of #143532 - compiler-errors:mut-ref-sugg, r=davidtwco
jhpratt Jul 9, 2025
ecea8e7
Rollup merge of #143606 - lambdageek:configure-write-last-key, r=Kobzol
jhpratt Jul 9, 2025
9e6fc2d
Rollup merge of #143632 - dillona:ffi-param-names, r=jieyouxu
jhpratt Jul 9, 2025
8989c62
Rollup merge of #143644 - Kobzol:stdarch-mention, r=Amanieu
jhpratt Jul 9, 2025
ae874bc
Rollup merge of #143651 - Fulgen301:seh-exception-ptr, r=ChrisDenton
jhpratt Jul 9, 2025
c29423e
Rollup merge of #143660 - cuviper:lib-doc-false, r=tgross35
jhpratt Jul 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Win: Use exceptions with empty data for SEH panic exception copies
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.
  • Loading branch information
Fulgen301 committed Jul 8, 2025
commit 96cdbb9ba77b9a840a1637e4dab05bb2cc64fef0
18 changes: 14 additions & 4 deletions library/panic_unwind/src/seh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ struct Exception {
// and its destructor is executed by the C++ runtime. When we take the Box
// out of the exception, we need to leave the exception in a valid state
// for its destructor to run without double-dropping the Box.
// We also construct this as None for copies of the exception.
data: Option<Box<dyn Any + Send>>,
}

Expand Down Expand Up @@ -264,7 +265,11 @@ static mut TYPE_DESCRIPTOR: _TypeDescriptor = _TypeDescriptor {
// runtime under a try/catch block and the panic that we generate here will be
// used as the result of the exception copy. This is used by the C++ runtime to
// support capturing exceptions with std::exception_ptr, which we can't support
// because Box<dyn Any> isn't clonable.
// because Box<dyn Any> isn't clonable. Thus we throw an exception without data,
// which the C++ runtime will attempt to copy, which will once again fail, and
// a std::bad_exception instance ends up in the std::exception_ptr instance.
// The lack of data doesn't matter because the exception will never be rethrown
// - it is purely used to signal to the C++ runtime that copying failed.
macro_rules! define_cleanup {
($abi:tt $abi2:tt) => {
unsafe extern $abi fn exception_cleanup(e: *mut Exception) {
Expand All @@ -278,7 +283,9 @@ macro_rules! define_cleanup {
unsafe extern $abi2 fn exception_copy(
_dest: *mut Exception, _src: *mut Exception
) -> *mut Exception {
panic!("Rust panics cannot be copied");
unsafe {
throw_exception(None);
}
}
}
}
Expand All @@ -291,6 +298,10 @@ cfg_if::cfg_if! {
}

pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
unsafe { throw_exception(Some(data)) }
}

unsafe fn throw_exception(data: Option<Box<dyn Any + Send>>) -> ! {
use core::intrinsics::{AtomicOrdering, atomic_store};

// _CxxThrowException executes entirely on this stack frame, so there's no
Expand All @@ -300,8 +311,7 @@ pub(crate) unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
// The ManuallyDrop is needed here since we don't want Exception to be
// dropped when unwinding. Instead it will be dropped by exception_cleanup
// which is invoked by the C++ runtime.
let mut exception =
ManuallyDrop::new(Exception { canary: (&raw const TYPE_DESCRIPTOR), data: Some(data) });
let mut exception = ManuallyDrop::new(Exception { canary: (&raw const TYPE_DESCRIPTOR), data });
let throw_ptr = (&raw mut exception) as *mut _;

// This... may seems surprising, and justifiably so. On 32-bit MSVC the
Expand Down
Loading