Skip to content

ICE: CValue::const_val for non bool/char/float/integer/pointer type Binder(extern "CCmseNonSecureCall" fn(i32, i32, i32, i32) -> i32, []) is not allowed #1430

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

fn main() {
    let non_secure_function =
        unsafe { core::mem::transmute::<usize, fn(i32, i32, i32, i32) -> i32>(0x10000004) };
    let mut toto = 5;
    toto += non_secure_function(toto, 2, 3, 5);
}

original:

#![feature(abi_c_cmse_nonsecure_call)]
// gate-test-abi_c_cmse_nonsecure_call
fn main() {
    let non_secure_function = unsafe {
        core::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(i32, i32, i32, i32) -> i32>(
        //~^ ERROR [E0658]
            0x10000004,
        )
    };
    let mut toto = 5;
    toto += non_secure_function(toto, 2, 3, 5);
}

Version information

rustc 1.76.0-nightly (eab8c7d5f 2023-11-24)
binary: rustc
commit-hash: eab8c7d5fd335d673bb96bb4aef86c74006cef4b
commit-date: 2023-11-24
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc -Zmir-opt-level=5 -Zcodegen-backend=cranelift

Program output

warning: value assigned to `toto` is never read
 --> /tmp/icemaker_global_tempdir.acC10d2Q4vK3/rustc_testrunner_tmpdir_reporting.NYMJJU80isW3/mvce.rs:5:5
  |
5 |     toto += non_secure_function(toto, 2, 3, 5);
  |     ^^^^
  |
  = help: maybe it is overwritten before being read?
  = note: `#[warn(unused_assignments)]` on by default

thread 'rustc' panicked at src/value_and_place.rs:342:18:
CValue::const_val for non bool/char/float/integer/pointer type Binder(fn(i32, i32, i32, i32) -> i32, []) is not allowed
stack backtrace:
   0:     0x7f4d7538aafc - std::backtrace_rs::backtrace::libunwind::trace::ha394ecedf818e8f9
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7f4d7538aafc - std::backtrace_rs::backtrace::trace_unsynchronized::h11a36c2d5206edef
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f4d7538aafc - std::sys_common::backtrace::_print_fmt::h667716e5716fc5b4
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7f4d7538aafc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hbff106ccc709ddc0
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7f4d753ddc80 - core::fmt::rt::Argument::fmt::hae8664174d462f48
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/core/src/fmt/rt.rs:142:9
   5:     0x7f4d753ddc80 - core::fmt::write::ha5b560f2667afda1
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/core/src/fmt/mod.rs:1120:17
   6:     0x7f4d7537e9af - std::io::Write::write_fmt::hb5fa4d68ba392e06
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/io/mod.rs:1762:15
   7:     0x7f4d7538a8e4 - std::sys_common::backtrace::_print::h4ad1f84781a78410
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7f4d7538a8e4 - std::sys_common::backtrace::print::h7903eaa441679c79
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7f4d7538d577 - std::panicking::default_hook::{{closure}}::h327025cc8106afbc
  10:     0x7f4d7538d2df - std::panicking::default_hook::he48288e882696fde
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/panicking.rs:292:9
  11:     0x7f4d780ff3d0 - std[cdfaf26f8336755a]::panicking::update_hook::<alloc[2b4b938bfc6c2157]::boxed::Box<rustc_driver_impl[3f866e89a4996194]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7f4d7538dcb8 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h37238316c568918f
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/alloc/src/boxed.rs:2021:9
  13:     0x7f4d7538dcb8 - std::panicking::rust_panic_with_hook::h71370366d59470e3
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/panicking.rs:783:13
  14:     0x7f4d7538da0e - std::panicking::begin_panic_handler::{{closure}}::h419a2625b0792f59
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/panicking.rs:657:13
  15:     0x7f4d7538afc6 - std::sys_common::backtrace::__rust_end_short_backtrace::h446acbf21087ff0c
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7f4d7538d772 - rust_begin_unwind
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/panicking.rs:645:5
  17:     0x7f4d753da365 - core::panicking::panic_fmt::h8822e21d044b4fb3
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/core/src/panicking.rs:72:14
  18:     0x7f4d6ba4a086 - <rustc_codegen_cranelift[e3380e7a25b72c72]::value_and_place::CValue>::const_val
  19:     0x7f4d6ba0da98 - rustc_codegen_cranelift[e3380e7a25b72c72]::constant::codegen_const_value
  20:     0x7f4d6ba06d57 - rustc_codegen_cranelift[e3380e7a25b72c72]::base::codegen_operand
  21:     0x7f4d6b9f4a80 - rustc_codegen_cranelift[e3380e7a25b72c72]::abi::codegen_terminator_call
  22:     0x7f4d6ba01f1d - rustc_codegen_cranelift[e3380e7a25b72c72]::base::codegen_fn_body
  23:     0x7f4d6ba17744 - rustc_codegen_cranelift[e3380e7a25b72c72]::driver::aot::module_codegen::{closure#0}
  24:     0x7f4d6ba14a55 - rustc_codegen_cranelift[e3380e7a25b72c72]::driver::aot::module_codegen
  25:     0x7f4d6ba2105c - rustc_codegen_cranelift[e3380e7a25b72c72]::driver::aot::run_aot
  26:     0x7f4d6ba4d3aa - <rustc_codegen_cranelift[e3380e7a25b72c72]::CraneliftCodegenBackend as rustc_codegen_ssa[b53b18222cf888e6]::traits::backend::CodegenBackend>::codegen_crate
  27:     0x7f4d79d8fd45 - rustc_interface[b5e35b18d6e1bfbd]::passes::start_codegen
  28:     0x7f4d79d8f49f - <rustc_interface[b5e35b18d6e1bfbd]::queries::Queries>::codegen_and_build_linker
  29:     0x7f4d79f2e906 - rustc_interface[b5e35b18d6e1bfbd]::interface::run_compiler::<core[e83fafa684db53ad]::result::Result<(), rustc_span[3a0bda970be190a8]::ErrorGuaranteed>, rustc_driver_impl[3f866e89a4996194]::run_compiler::{closure#0}>::{closure#0}
  30:     0x7f4d7a3a2c14 - std[cdfaf26f8336755a]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[b5e35b18d6e1bfbd]::util::run_in_thread_with_globals<rustc_interface[b5e35b18d6e1bfbd]::util::run_in_thread_pool_with_globals<rustc_interface[b5e35b18d6e1bfbd]::interface::run_compiler<core[e83fafa684db53ad]::result::Result<(), rustc_span[3a0bda970be190a8]::ErrorGuaranteed>, rustc_driver_impl[3f866e89a4996194]::run_compiler::{closure#0}>::{closure#0}, core[e83fafa684db53ad]::result::Result<(), rustc_span[3a0bda970be190a8]::ErrorGuaranteed>>::{closure#0}, core[e83fafa684db53ad]::result::Result<(), rustc_span[3a0bda970be190a8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e83fafa684db53ad]::result::Result<(), rustc_span[3a0bda970be190a8]::ErrorGuaranteed>>
  31:     0x7f4d7a3a2a3d - <<std[cdfaf26f8336755a]::thread::Builder>::spawn_unchecked_<rustc_interface[b5e35b18d6e1bfbd]::util::run_in_thread_with_globals<rustc_interface[b5e35b18d6e1bfbd]::util::run_in_thread_pool_with_globals<rustc_interface[b5e35b18d6e1bfbd]::interface::run_compiler<core[e83fafa684db53ad]::result::Result<(), rustc_span[3a0bda970be190a8]::ErrorGuaranteed>, rustc_driver_impl[3f866e89a4996194]::run_compiler::{closure#0}>::{closure#0}, core[e83fafa684db53ad]::result::Result<(), rustc_span[3a0bda970be190a8]::ErrorGuaranteed>>::{closure#0}, core[e83fafa684db53ad]::result::Result<(), rustc_span[3a0bda970be190a8]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[e83fafa684db53ad]::result::Result<(), rustc_span[3a0bda970be190a8]::ErrorGuaranteed>>::{closure#1} as core[e83fafa684db53ad]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  32:     0x7f4d75397b75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h9468334d88a3ef49
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/alloc/src/boxed.rs:2007:9
  33:     0x7f4d75397b75 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4c14117afdd51454
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/alloc/src/boxed.rs:2007:9
  34:     0x7f4d75397b75 - std::sys::unix::thread::Thread::new::thread_start::hdf49c58b2d5b911a
                               at /rustc/eab8c7d5fd335d673bb96bb4aef86c74006cef4b/library/std/src/sys/unix/thread.rs:108:17
  35:     0x7f4d751889eb - <unknown>
  36:     0x7f4d7520c7cc - <unknown>
  37:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

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: rustc 1.76.0-nightly (eab8c7d5f 2023-11-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z mir-opt-level=5 -Z codegen-backend=cranelift -Z dump-mir-dir=dir

query stack during panic:
end of query stack
warning: 1 warning emitted


Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions