Skip to content

Non-native u128 saturating ops causes ICE #155

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

Closed
yvt opened this issue Mar 31, 2022 · 2 comments · Fixed by #156
Closed

Non-native u128 saturating ops causes ICE #155

yvt opened this issue Mar 31, 2022 · 2 comments · Fixed by #156
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@yvt
Copy link
Contributor

yvt commented Mar 31, 2022

assert_eq!(var.saturating_add(argc as u128), 134217857);
assert_eq!(var.saturating_sub(argc as u128), 134217855);

Output:

libgccjit.so: error: gcc_jit_context_new_binary_op: gcc_jit_binary_op GCC_JIT_BINARY_OP_PLUS with operands a: param0 b: param1 has non-numeric result_type: __uint64_t[2]
thread 'rustc' panicked at 'gcc_jit_context_new_binary_op: gcc_jit_binary_op GCC_JIT_BINARY_OP_PLUS with operands a: param0 b: param1 has non-numeric result_type: __uint64_t[2]', .../.cargo/git/checkouts/gccjit.rs-13c2e290f2fb9e4d/f24e1f4/src/rvalue.rs:85:1
stack backtrace:
   0:     0x7f22b894859d - std::backtrace_rs::backtrace::libunwind::trace::h4f2e7ab643c2a72d
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x7f22b894859d - std::backtrace_rs::backtrace::trace_unsynchronized::hd8122d89d466155f
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f22b894859d - std::sys_common::backtrace::_print_fmt::ha14304a8be4cab4e
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/sys_common/backtrace.rs:66:5
   3:     0x7f22b894859d - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h678e56b07ae20456
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/sys_common/backtrace.rs:45:22
   4:     0x7f22b89a259c - core::fmt::write::he02f153a6985c4ab
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/core/src/fmt/mod.rs:1190:17
   5:     0x7f22b8939b91 - std::io::Write::write_fmt::h7060a030ecb1908e
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/io/mod.rs:1655:15
   6:     0x7f22b894b685 - std::sys_common::backtrace::_print::h43aa906fea8f5fa6
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/sys_common/backtrace.rs:48:5
   7:     0x7f22b894b685 - std::sys_common::backtrace::print::h983a1d6d27ade7a7
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/sys_common/backtrace.rs:35:9
   8:     0x7f22b894b685 - std::panicking::default_hook::{{closure}}::h2519cebbcdfbe142
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/panicking.rs:295:22
   9:     0x7f22b894b339 - std::panicking::default_hook::hd3049586fce1b82d
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/panicking.rs:314:9
  10:     0x7f22b9127491 - rustc_driver[38891ed57d3cc9fe]::DEFAULT_HOOK::{closure#0}::{closure#0}
  11:     0x7f22b894bdd0 - std::panicking::rust_panic_with_hook::he52c9b5b92154d6b
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/panicking.rs:702:17
  12:     0x7f22b894bc07 - std::panicking::begin_panic_handler::{{closure}}::hf018eb13cb3893ab
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/panicking.rs:588:13
  13:     0x7f22b8948a54 - std::sys_common::backtrace::__rust_end_short_backtrace::h5d4c345c9dd5a5f5
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/sys_common/backtrace.rs:138:18
  14:     0x7f22b894b939 - rust_begin_unwind
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/std/src/panicking.rs:584:5
  15:     0x7f22b890fa33 - core::panicking::panic_fmt::hd20d5a3762e7a99c
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/core/src/panicking.rs:143:14
  16:     0x7f22b16abe21 - core::panicking::panic_display::ha284f56ce9ed4b08
                               at /rustc/d53246fedde4c193eae8a003546a8f0f9f85d223/library/core/src/panicking.rs:72:5
  17:     0x7f22b16ac04d - <gccjit::rvalue::RValue as core::ops::arith::Add>::add::hf895c7365afe4b37
                               at .../.cargo/git/checkouts/gccjit.rs-13c2e290f2fb9e4d/f24e1f4/src/rvalue.rs:75:25
  18:     0x7f22b144f901 - rustc_codegen_gcc::intrinsic::<impl rustc_codegen_gcc::builder::Builder>::saturating_add::h4f45b18e6cf83874
                               at .../rustc_codegen_gcc/src/intrinsic/mod.rs:1010:23
  19:     0x7f22b1449033 - rustc_codegen_gcc::intrinsic::<impl rustc_codegen_ssa::traits::intrinsic::IntrinsicCallMethods for rustc_codegen_gcc::builder::Builder>::codegen_intrinsic_call::h9dcefba0fc1f7ae5

Version: 403e198 + rust-lang/gcc@141e034

@yvt yvt changed the title u128 saturating ops causes ICE with non-native 128-bit integer types Non-native u128 saturating ops causes ICE Mar 31, 2022
@antoyo
Copy link
Contributor

antoyo commented Mar 31, 2022

Thanks for reporting this issue!

It seems some intrinsics weren't updated to use non-native integer operations.
I'm pretty sure that it wouldn't work on i128 either.

Perhaps we should run libstd's tests in the CI as this would allow to see more of what doesn't work on non-native integers.
I recall having trouble running those tests, though.

@antoyo antoyo added bug Something isn't working good first issue Good for newcomers labels Mar 31, 2022
@yvt
Copy link
Contributor Author

yvt commented Apr 1, 2022

I'd like to take a stab at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants