Skip to content

Commit

Permalink
Revert MOZ\0RUST endianness
Browse files Browse the repository at this point in the history
This was changed in upstream Rust recently [1], so change to follow
suit. The error message is slightly different between
exception from another Rust runtime and a complete foreign exception.
(The message for later is a confusing "Rust exception must be
rethrown").

Link: rust-lang/rust#130381 [1]
  • Loading branch information
nbdd0121 committed Oct 8, 2024
1 parent e651ead commit 6207ede
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/panicking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub fn begin_panic<E: Exception>(exception: E) -> UnwindReasonCode {

let ex = E::wrap(exception);
unsafe {
(*ex).exception_class = u64::from_be_bytes(E::CLASS);
(*ex).exception_class = u64::from_ne_bytes(E::CLASS);
(*ex).exception_cleanup = Some(exception_cleanup::<E>);
_Unwind_RaiseException(ex)
}
Expand Down Expand Up @@ -60,7 +60,7 @@ pub fn catch_unwind<E: Exception, R, F: FnOnce() -> R>(f: F) -> Result<R, Option
unsafe {
let data = &mut *(data as *mut ManuallyDrop<Option<E>>);
let exception = exception as *mut UnwindException;
if (*exception).exception_class != u64::from_be_bytes(E::CLASS) {
if (*exception).exception_class != u64::from_ne_bytes(E::CLASS) {
_Unwind_DeleteException(exception);
*data = ManuallyDrop::new(None);
return;
Expand Down

2 comments on commit 6207ede

@RalfJung
Copy link

@RalfJung RalfJung commented on 6207ede Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was changed in upstream Rust recently

rust-lang/rust#130381 did not intended to change anything, it was meant to make the existing code more clear. Is that not what happened?

EDIT: I confirmed that this PR did not change anything.

@nbdd0121
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I quoted the wrong PR in the commit message, should be rust-lang/rust#130897

Please sign in to comment.