Skip to content
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

is_val_statically_known: ICE with different args #120480

Closed
klensy opened this issue Jan 29, 2024 · 5 comments · Fixed by #120484
Closed

is_val_statically_known: ICE with different args #120480

klensy opened this issue Jan 29, 2024 · 5 comments · Fixed by #120484
Assignees
Labels
C-bug Category: This is a bug. F-core_intrinsics Issue in the "core intrinsics" for internal usage only. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@klensy
Copy link
Contributor

klensy commented Jan 29, 2024

Code1

#![feature(core_intrinsics)]
use std::intrinsics::is_val_statically_known;


pub fn foo(x:&u8)->bool{
    if unsafe{ is_val_statically_known(x)}{
        true
    }
    else{
        true
    }
}

Code 2

#![feature(core_intrinsics)]
use std::intrinsics::is_val_statically_known;


pub fn foo(x:&[u8])->bool{
    if unsafe{ is_val_statically_known(x)}{
        true
    }
    else{
        true
    }
}

Few ICEs with new intrinsic
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=cb804433ecbb2a93b148f472302cc0ef:
https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=863b2a8afb2364a85f572a57c57ad322:

Meta

rustc --version --verbose:

Build using the Nightly version: 1.77.0-nightly

(2024-01-27 635124704849eeead4e3)

Error output 1

error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:638:55: unknown intrinsic 'llvm.is.constant.ptr'
Backtrace 1

error: internal compiler error: compiler/rustc_codegen_llvm/src/context.rs:638:55: unknown intrinsic 'llvm.is.constant.ptr'

thread 'rustc' panicked at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/compiler/rustc_errors/src/lib.rs:926:30:
Box<dyn Any>
stack backtrace:
   0:     0x7f9bf04d6706 - std::backtrace_rs::backtrace::libunwind::trace::hab3572c31eb20106
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f9bf04d6706 - std::backtrace_rs::backtrace::trace_unsynchronized::h60fe86980a447e1f
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f9bf04d6706 - std::sys_common::backtrace::_print_fmt::h94f8d95d56c8f54a
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f9bf04d6706 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hcc8bd1ee8b27b1a7
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f9bf05290a0 - core::fmt::rt::Argument::fmt::h53aa1e305ab9c913
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/core/src/fmt/rt.rs:142:9
   5:     0x7f9bf05290a0 - core::fmt::write::h510b9470c0914af3
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f9bf04ca03f - std::io::Write::write_fmt::h324f538b1fa72cf5
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/io/mod.rs:1810:15
   7:     0x7f9bf04d64e4 - std::sys_common::backtrace::_print::h87616c284c3fd658
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f9bf04d64e4 - std::sys_common::backtrace::print::h1a5bdc383314a847
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f9bf04d9277 - std::panicking::default_hook::{{closure}}::h154ee088de97fd79
  10:     0x7f9bf04d8fd9 - std::panicking::default_hook::h255191adadb3bbd3
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/panicking.rs:292:9
  11:     0x7f9bf32979cc - std[9b9743348aa3637e]::panicking::update_hook::<alloc[bafad8be7e602ddc]::boxed::Box<rustc_driver_impl[15253732b01127ee]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f9bf04d99c6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::he0826d83a3d5350a
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/alloc/src/boxed.rs:2029:9
  13:     0x7f9bf04d99c6 - std::panicking::rust_panic_with_hook::h48fa132e308b8b90
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/panicking.rs:785:13
  14:     0x7f9bf32c98f4 - std[9b9743348aa3637e]::panicking::begin_panic::<rustc_errors[d03769001d3e1f62]::ExplicitBug>::{closure#0}
  15:     0x7f9bf32c6336 - std[9b9743348aa3637e]::sys_common::backtrace::__rust_end_short_backtrace::<std[9b9743348aa3637e]::panicking::begin_panic<rustc_errors[d03769001d3e1f62]::ExplicitBug>::{closure#0}, !>
  16:     0x7f9bf32c5ce6 - std[9b9743348aa3637e]::panicking::begin_panic::<rustc_errors[d03769001d3e1f62]::ExplicitBug>
  17:     0x7f9bf32d4821 - <rustc_errors[d03769001d3e1f62]::diagnostic_builder::BugAbort as rustc_errors[d03769001d3e1f62]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7f9bf36922cb - <rustc_errors[d03769001d3e1f62]::DiagCtxt>::bug::<alloc[bafad8be7e602ddc]::string::String>
  19:     0x7f9bf37292cb - rustc_middle[16339a7d2af1bee1]::util::bug::opt_span_bug_fmt::<rustc_span[f446feb06f8d21a5]::span_encoding::Span>::{closure#0}
  20:     0x7f9bf371196a - rustc_middle[16339a7d2af1bee1]::ty::context::tls::with_opt::<rustc_middle[16339a7d2af1bee1]::util::bug::opt_span_bug_fmt<rustc_span[f446feb06f8d21a5]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f9bf37117e8 - rustc_middle[16339a7d2af1bee1]::ty::context::tls::with_context_opt::<rustc_middle[16339a7d2af1bee1]::ty::context::tls::with_opt<rustc_middle[16339a7d2af1bee1]::util::bug::opt_span_bug_fmt<rustc_span[f446feb06f8d21a5]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f9bf16b4880 - rustc_middle[16339a7d2af1bee1]::util::bug::bug_fmt
  23:     0x7f9bf5af3ba6 - <rustc_codegen_llvm[840ef9f4dc4837b2]::context::CodegenCx>::get_intrinsic.cold.0
  24:     0x7f9bf50721ac - <rustc_codegen_llvm[840ef9f4dc4837b2]::builder::Builder as rustc_codegen_ssa[67b83b73dc7928ce]::traits::intrinsic::IntrinsicCallMethods>::codegen_intrinsic_call
  25:     0x7f9bf519ce80 - <rustc_codegen_ssa[67b83b73dc7928ce]::mir::FunctionCx<rustc_codegen_llvm[840ef9f4dc4837b2]::builder::Builder>>::codegen_intrinsic_call
  26:     0x7f9bf4f3c7bc - <rustc_codegen_ssa[67b83b73dc7928ce]::mir::FunctionCx<rustc_codegen_llvm[840ef9f4dc4837b2]::builder::Builder>>::codegen_block
  27:     0x7f9bf50cf475 - rustc_codegen_ssa[67b83b73dc7928ce]::mir::codegen_mir::<rustc_codegen_llvm[840ef9f4dc4837b2]::builder::Builder>
  28:     0x7f9bf50bc968 - rustc_codegen_llvm[840ef9f4dc4837b2]::base::compile_codegen_unit::module_codegen
  29:     0x7f9bf54ccead - <rustc_codegen_llvm[840ef9f4dc4837b2]::LlvmCodegenBackend as rustc_codegen_ssa[67b83b73dc7928ce]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  30:     0x7f9bf54d93c3 - rustc_codegen_ssa[67b83b73dc7928ce]::base::codegen_crate::<rustc_codegen_llvm[840ef9f4dc4837b2]::LlvmCodegenBackend>
  31:     0x7f9bf54d8af5 - <rustc_codegen_llvm[840ef9f4dc4837b2]::LlvmCodegenBackend as rustc_codegen_ssa[67b83b73dc7928ce]::traits::backend::CodegenBackend>::codegen_crate
  32:     0x7f9bf54d6ef0 - rustc_interface[2c240f1a557fc091]::passes::start_codegen
  33:     0x7f9bf54d6630 - <rustc_interface[2c240f1a557fc091]::queries::Queries>::codegen_and_build_linker
  34:     0x7f9bf5281a8a - rustc_interface[2c240f1a557fc091]::interface::run_compiler::<core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>, rustc_driver_impl[15253732b01127ee]::run_compiler::{closure#0}>::{closure#0}
  35:     0x7f9bf4eb7706 - std[9b9743348aa3637e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[2c240f1a557fc091]::util::run_in_thread_with_globals<rustc_interface[2c240f1a557fc091]::util::run_in_thread_pool_with_globals<rustc_interface[2c240f1a557fc091]::interface::run_compiler<core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>, rustc_driver_impl[15253732b01127ee]::run_compiler::{closure#0}>::{closure#0}, core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>>::{closure#0}, core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>>
  36:     0x7f9bf4eb7533 - <<std[9b9743348aa3637e]::thread::Builder>::spawn_unchecked_<rustc_interface[2c240f1a557fc091]::util::run_in_thread_with_globals<rustc_interface[2c240f1a557fc091]::util::run_in_thread_pool_with_globals<rustc_interface[2c240f1a557fc091]::interface::run_compiler<core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>, rustc_driver_impl[15253732b01127ee]::run_compiler::{closure#0}>::{closure#0}, core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>>::{closure#0}, core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>>::{closure#1} as core[2c84ace8ac8a7133]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  37:     0x7f9bf04e2fb5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h81eeb26d82351c2e
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/alloc/src/boxed.rs:2015:9
  38:     0x7f9bf04e2fb5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha4fb1b693e599c2e
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/alloc/src/boxed.rs:2015:9
  39:     0x7f9bf04e2fb5 - std::sys::pal::unix::thread::Thread::new::thread_start::hbbc84e063a1942c6
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/sys/pal/unix/thread.rs:108:17
  40:     0x7f9bf03f5609 - start_thread
  41:     0x7f9bf0318353 - clone
  42:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please attach the file at `/playground/rustc-ice-2024-01-29T21_18_49-20.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

note: some of the compiler flags provided by cargo are hidden

Error output 2

error: internal compiler error: /rustc/635124704849eeead4e3a7bb6e663c5351571d93/compiler/rustc_codegen_ssa/src/mir/operand.rs:201:18: not immediate: OperandRef(Pair((ptr:ptr %0), (i64:i64 %1)) @ TyAndLayout { ty: &[u8], layout: Layout { size: Size(16 bytes), align: AbiAndPrefAlign { abi: Align(8 bytes), pref: Align(8 bytes) }, abi: ScalarPair(Initialized { value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }, Initialized { value: Int(I64, false), valid_range: 0..=18446744073709551615 }), fields: Arbitrary { offsets: [Size(0 bytes), Size(8 bytes)], memory_index: [0, 1] }, largest_niche: Some(Niche { offset: Size(0 bytes), value: Pointer(AddressSpace(0)), valid_range: 1..=18446744073709551615 }), variants: Single { index: 0 }, max_repr_align: None, unadjusted_abi_align: Align(8 bytes) } })

Backtrace 2

thread 'rustc' panicked at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/compiler/rustc_errors/src/lib.rs:926:30:
Box<dyn Any>
stack backtrace:
   0:     0x7f13ef557706 - std::backtrace_rs::backtrace::libunwind::trace::hab3572c31eb20106
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f13ef557706 - std::backtrace_rs::backtrace::trace_unsynchronized::h60fe86980a447e1f
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f13ef557706 - std::sys_common::backtrace::_print_fmt::h94f8d95d56c8f54a
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f13ef557706 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hcc8bd1ee8b27b1a7
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f13ef5aa0a0 - core::fmt::rt::Argument::fmt::h53aa1e305ab9c913
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/core/src/fmt/rt.rs:142:9
   5:     0x7f13ef5aa0a0 - core::fmt::write::h510b9470c0914af3
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f13ef54b03f - std::io::Write::write_fmt::h324f538b1fa72cf5
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/io/mod.rs:1810:15
   7:     0x7f13ef5574e4 - std::sys_common::backtrace::_print::h87616c284c3fd658
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f13ef5574e4 - std::sys_common::backtrace::print::h1a5bdc383314a847
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f13ef55a277 - std::panicking::default_hook::{{closure}}::h154ee088de97fd79
  10:     0x7f13ef559fd9 - std::panicking::default_hook::h255191adadb3bbd3
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/panicking.rs:292:9
  11:     0x7f13f23189cc - std[9b9743348aa3637e]::panicking::update_hook::<alloc[bafad8be7e602ddc]::boxed::Box<rustc_driver_impl[15253732b01127ee]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f13ef55a9c6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::he0826d83a3d5350a
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/alloc/src/boxed.rs:2029:9
  13:     0x7f13ef55a9c6 - std::panicking::rust_panic_with_hook::h48fa132e308b8b90
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/panicking.rs:785:13
  14:     0x7f13f234a8f4 - std[9b9743348aa3637e]::panicking::begin_panic::<rustc_errors[d03769001d3e1f62]::ExplicitBug>::{closure#0}
  15:     0x7f13f2347336 - std[9b9743348aa3637e]::sys_common::backtrace::__rust_end_short_backtrace::<std[9b9743348aa3637e]::panicking::begin_panic<rustc_errors[d03769001d3e1f62]::ExplicitBug>::{closure#0}, !>
  16:     0x7f13f2346ce6 - std[9b9743348aa3637e]::panicking::begin_panic::<rustc_errors[d03769001d3e1f62]::ExplicitBug>
  17:     0x7f13f2355821 - <rustc_errors[d03769001d3e1f62]::diagnostic_builder::BugAbort as rustc_errors[d03769001d3e1f62]::diagnostic_builder::EmissionGuarantee>::emit_producing_guarantee
  18:     0x7f13f27132cb - <rustc_errors[d03769001d3e1f62]::DiagCtxt>::bug::<alloc[bafad8be7e602ddc]::string::String>
  19:     0x7f13f27aa2cb - rustc_middle[16339a7d2af1bee1]::util::bug::opt_span_bug_fmt::<rustc_span[f446feb06f8d21a5]::span_encoding::Span>::{closure#0}
  20:     0x7f13f279296a - rustc_middle[16339a7d2af1bee1]::ty::context::tls::with_opt::<rustc_middle[16339a7d2af1bee1]::util::bug::opt_span_bug_fmt<rustc_span[f446feb06f8d21a5]::span_encoding::Span>::{closure#0}, !>::{closure#0}
  21:     0x7f13f27927e8 - rustc_middle[16339a7d2af1bee1]::ty::context::tls::with_context_opt::<rustc_middle[16339a7d2af1bee1]::ty::context::tls::with_opt<rustc_middle[16339a7d2af1bee1]::util::bug::opt_span_bug_fmt<rustc_span[f446feb06f8d21a5]::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
  22:     0x7f13f0735880 - rustc_middle[16339a7d2af1bee1]::util::bug::bug_fmt
  23:     0x7f13f40f3b86 - <rustc_codegen_llvm[840ef9f4dc4837b2]::builder::Builder as rustc_codegen_ssa[67b83b73dc7928ce]::traits::intrinsic::IntrinsicCallMethods>::codegen_intrinsic_call
  24:     0x7f13f421de80 - <rustc_codegen_ssa[67b83b73dc7928ce]::mir::FunctionCx<rustc_codegen_llvm[840ef9f4dc4837b2]::builder::Builder>>::codegen_intrinsic_call
  25:     0x7f13f3fbd7bc - <rustc_codegen_ssa[67b83b73dc7928ce]::mir::FunctionCx<rustc_codegen_llvm[840ef9f4dc4837b2]::builder::Builder>>::codegen_block
  26:     0x7f13f4150475 - rustc_codegen_ssa[67b83b73dc7928ce]::mir::codegen_mir::<rustc_codegen_llvm[840ef9f4dc4837b2]::builder::Builder>
  27:     0x7f13f413d968 - rustc_codegen_llvm[840ef9f4dc4837b2]::base::compile_codegen_unit::module_codegen
  28:     0x7f13f454dead - <rustc_codegen_llvm[840ef9f4dc4837b2]::LlvmCodegenBackend as rustc_codegen_ssa[67b83b73dc7928ce]::traits::backend::ExtraBackendMethods>::compile_codegen_unit
  29:     0x7f13f455a3c3 - rustc_codegen_ssa[67b83b73dc7928ce]::base::codegen_crate::<rustc_codegen_llvm[840ef9f4dc4837b2]::LlvmCodegenBackend>
  30:     0x7f13f4559af5 - <rustc_codegen_llvm[840ef9f4dc4837b2]::LlvmCodegenBackend as rustc_codegen_ssa[67b83b73dc7928ce]::traits::backend::CodegenBackend>::codegen_crate
  31:     0x7f13f4557ef0 - rustc_interface[2c240f1a557fc091]::passes::start_codegen
  32:     0x7f13f4557630 - <rustc_interface[2c240f1a557fc091]::queries::Queries>::codegen_and_build_linker
  33:     0x7f13f4302a8a - rustc_interface[2c240f1a557fc091]::interface::run_compiler::<core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>, rustc_driver_impl[15253732b01127ee]::run_compiler::{closure#0}>::{closure#0}
  34:     0x7f13f3f38706 - std[9b9743348aa3637e]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[2c240f1a557fc091]::util::run_in_thread_with_globals<rustc_interface[2c240f1a557fc091]::util::run_in_thread_pool_with_globals<rustc_interface[2c240f1a557fc091]::interface::run_compiler<core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>, rustc_driver_impl[15253732b01127ee]::run_compiler::{closure#0}>::{closure#0}, core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>>::{closure#0}, core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>>
  35:     0x7f13f3f38533 - <<std[9b9743348aa3637e]::thread::Builder>::spawn_unchecked_<rustc_interface[2c240f1a557fc091]::util::run_in_thread_with_globals<rustc_interface[2c240f1a557fc091]::util::run_in_thread_pool_with_globals<rustc_interface[2c240f1a557fc091]::interface::run_compiler<core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>, rustc_driver_impl[15253732b01127ee]::run_compiler::{closure#0}>::{closure#0}, core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>>::{closure#0}, core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2c84ace8ac8a7133]::result::Result<(), rustc_span[f446feb06f8d21a5]::ErrorGuaranteed>>::{closure#1} as core[2c84ace8ac8a7133]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  36:     0x7f13ef563fb5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h81eeb26d82351c2e
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/alloc/src/boxed.rs:2015:9
  37:     0x7f13ef563fb5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::ha4fb1b693e599c2e
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/alloc/src/boxed.rs:2015:9
  38:     0x7f13ef563fb5 - std::sys::pal::unix::thread::Thread::new::thread_start::hbbc84e063a1942c6
                               at /rustc/635124704849eeead4e3a7bb6e663c5351571d93/library/std/src/sys/pal/unix/thread.rs:108:17
  39:     0x7f13ef476609 - start_thread
  40:     0x7f13ef399353 - clone
  41:                0x0 - <unknown>

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: please attach the file at `/playground/rustc-ice-2024-01-29T21_21_43-17.txt` to your bug report

note: compiler flags: --crate-type lib -C embed-bitcode=no -C codegen-units=1 -C debuginfo=2

#119911, so cc @NCGThompson

@klensy klensy added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 29, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jan 29, 2024
@Teapot4195
Copy link
Contributor

Teapot4195 commented Jan 29, 2024

  1. Looks like the llvm.is.constant.ptr intrinsic wasn't added to the list at compiler/rustc_codegen_llvm/src/context.rs:677
  2. 2 Appears to be the same crash, just panicking at different points.

@rustbot label +F-core_intrinsics -needs-triage

@rustbot rustbot added F-core_intrinsics Issue in the "core intrinsics" for internal usage only. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 29, 2024
@Teapot4195
Copy link
Contributor

@rustbot claim

@NCGThompson
Copy link
Contributor

  1. Looks like the llvm.is.constant.ptr intrinsic wasn't added to the list at compiler/rustc_codegen_llvm/src/context.rs:677

@Teapot4195 Would that check if the pointer address is constant or the referenced value is constant? I think for &u8, one would expect the reference to be coerced to a u8. I don't know what to do for slices though.

@Teapot4195
Copy link
Contributor

  1. Looks like the llvm.is.constant.ptr intrinsic wasn't added to the list at compiler/rustc_codegen_llvm/src/context.rs:677

@Teapot4195 Would that check if the pointer address is constant or the referenced value is constant? I think for &u8, one would expect the reference to be coerced to a u8. I don't know what to do for slices though.

I think llvm.is.constant.ptr checks for whether or not the the pointer address is statically known. I don't think mutable variables in function bodies can be statically known and references to globals are guaranteed to fold to false.

That covers all the cases I thought about but I'm fairly confident I missed something.

@NCGThompson
Copy link
Contributor

NCGThompson commented Jan 30, 2024

I don't think mutable variables in function bodies can be statically known

They can be. It is usually the result of inlineing. Detecting that is kind of the point of the intrinsic.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 31, 2024
…piler-errors

Avoid ICE when is_val_statically_known is not of a supported type

2 ICE with 1 stone!
1. Implement `llvm.is.constant.ptr` to avoid first ICE in linked issue.
2. return `false` when the argument is not one of `i*`/`f*`/`ptr` to avoid second ICE.

fixes rust-lang#120480
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 31, 2024
…piler-errors

Avoid ICE when is_val_statically_known is not of a supported type

2 ICE with 1 stone!
1. Implement `llvm.is.constant.ptr` to avoid first ICE in linked issue.
2. return `false` when the argument is not one of `i*`/`f*`/`ptr` to avoid second ICE.

fixes rust-lang#120480
@bors bors closed this as completed in 6f24836 Feb 4, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Feb 4, 2024
Rollup merge of rust-lang#120484 - Teapot4195:issue-120480-fix, r=compiler-errors

Avoid ICE when is_val_statically_known is not of a supported type

2 ICE with 1 stone!
1. Implement `llvm.is.constant.ptr` to avoid first ICE in linked issue.
2. return `false` when the argument is not one of `i*`/`f*`/`ptr` to avoid second ICE.

fixes rust-lang#120480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-core_intrinsics Issue in the "core intrinsics" for internal usage only. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants