-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NaNs are quieted on Emscripten #136197
Comments
This appears to be caused by catching unwinds: struct Droppable;
impl Drop for Droppable {
fn drop(&mut self) {}
}
const NOT_CANNONICAL_F32: f32 = f32::from_bits(f32::NAN.to_bits() | 1);
const NOT_CANNONICAL_F64: f64 = f64::from_bits(f64::NAN.to_bits() | 1);
// The issue will only occur when compiled with panic=unwind.
fn main() {
// Commenting out the line below will make the issue disappear.
let _x = Droppable;
// This affects both function arguments and function return values.
// These should both print 7fc00001 but will instead print 7fc00000.
print_float_f32(NOT_CANNONICAL_F32);
print_hex_f32(unsafe { std::mem::transmute::<f32, u32>(get_float_f32()) });
// These should both print 7ff8000000000001 but will instead print 7ff8000000000000.
print_float_f64(NOT_CANNONICAL_F64);
print_hex_f64(unsafe { std::mem::transmute::<f64, u64>(get_float_f64()) });
}
#[inline(never)]
fn get_float_f32() -> f32 {
NOT_CANNONICAL_F32
}
#[inline(never)]
fn get_float_f64() -> f64 {
NOT_CANNONICAL_F64
}
#[inline(never)]
fn print_float_f32(x: f32) {
print_hex_f32(unsafe { std::mem::transmute::<f32, u32>(x) })
}
#[inline(never)]
fn print_float_f64(x: f64) {
print_hex_f64(unsafe { std::mem::transmute::<f64, u64>(x) })
}
#[inline(never)]
fn print_hex_f32(x: u32) {
println!("{:x}", x);
}
#[inline(never)]
fn print_hex_f64(x: u64) {
println!("{:x}", x);
} When Emscripten wants to catch an unwind, it trampolines the function call via one of the @rustbot label -E-needs-investigation +A-LLVM |
Good to know, thanks. This must be emscripten-core/emscripten#22743. The consensus seems to be we should "just" switch to new EH ABI, which fixes this bug. |
…jieyouxu Fix a couple Emscripten tests This fixes a couple Emscripten tests where the correct fix is more or less obvious. A couple UI tests are still broken with this PR: - `tests/ui/abi/numbers-arithmetic/return-float.rs` (rust-lang#136197) - `tests/ui/no_std/no-std-unwind-binary.rs` (haven't debugged yet) - `tests/ui/test-attrs/test-passed.rs` (haven't debugged this either) `@rustbot` label +T-compiler +O-emscripten
…jieyouxu Fix a couple Emscripten tests This fixes a couple Emscripten tests where the correct fix is more or less obvious. A couple UI tests are still broken with this PR: - `tests/ui/abi/numbers-arithmetic/return-float.rs` (rust-lang#136197) - `tests/ui/no_std/no-std-unwind-binary.rs` (haven't debugged yet) - `tests/ui/test-attrs/test-passed.rs` (haven't debugged this either) ``@rustbot`` label +T-compiler +O-emscripten
…jieyouxu Fix a couple Emscripten tests This fixes a couple Emscripten tests where the correct fix is more or less obvious. A couple UI tests are still broken with this PR: - `tests/ui/abi/numbers-arithmetic/return-float.rs` (rust-lang#136197) - `tests/ui/no_std/no-std-unwind-binary.rs` (haven't debugged yet) - `tests/ui/test-attrs/test-passed.rs` (haven't debugged this either) ```@rustbot``` label +T-compiler +O-emscripten
…jieyouxu Fix a couple Emscripten tests This fixes a couple Emscripten tests where the correct fix is more or less obvious. A couple UI tests are still broken with this PR: - `tests/ui/abi/numbers-arithmetic/return-float.rs` (rust-lang#136197) - `tests/ui/no_std/no-std-unwind-binary.rs` (haven't debugged yet) - `tests/ui/test-attrs/test-passed.rs` (haven't debugged this either) ````@rustbot```` label +T-compiler +O-emscripten
…jieyouxu Fix a couple Emscripten tests This fixes a couple Emscripten tests where the correct fix is more or less obvious. A couple UI tests are still broken with this PR: - `tests/ui/abi/numbers-arithmetic/return-float.rs` (rust-lang#136197) - `tests/ui/no_std/no-std-unwind-binary.rs` (haven't debugged yet) - `tests/ui/test-attrs/test-passed.rs` (haven't debugged this either) `````@rustbot````` label +T-compiler +O-emscripten
Rollup merge of rust-lang#136199 - purplesyringa:emscripten-tests, r=jieyouxu Fix a couple Emscripten tests This fixes a couple Emscripten tests where the correct fix is more or less obvious. A couple UI tests are still broken with this PR: - `tests/ui/abi/numbers-arithmetic/return-float.rs` (rust-lang#136197) - `tests/ui/no_std/no-std-unwind-binary.rs` (haven't debugged yet) - `tests/ui/test-attrs/test-passed.rs` (haven't debugged this either) `````@rustbot````` label +T-compiler +O-emscripten
tests/ui/abi/numbers-arithmetic/return-float.rs
currently fails underwasm32-unknown-emscripten
:This reproduces on 66d6064 on Node v23.6.0. WASI is fine, and I think it uses Node during tests too, so probably not a Node bug.
@rustbot label +A-ABI +A-floating-point +I-miscompile +O-emscripten +T-compiler +E-needs-investigation
The text was updated successfully, but these errors were encountered: