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

analyze: ICE on pointer transmute #996

Open
spernsteiner opened this issue Jul 18, 2023 · 0 comments · May be fixed by #999
Open

analyze: ICE on pointer transmute #996

spernsteiner opened this issue Jul 18, 2023 · 0 comments · May be fixed by #999
Assignees

Comments

@spernsteiner
Copy link
Contributor

unsafe fn f(x: *const u8) -> *const i8 {
    std::mem::transmute(x)
}

Triggers an internal compiler error:

visit_terminator(_0 = std::intrinsics::transmute::<*const u8, *const i8>(move _2) -> [return: bb1, unwind: bb2])
unsafe extern "rust-intrinsic" fn(*const u8) -> *const i8 {std::intrinsics::transmute::<*const u8, *const i8>} is trivial: false
name: "transmute"
callee = UnknownDef(Direct { ty: unsafe extern "rust-intrinsic" fn(*const u8) -> *const i8 {std::intrinsics::transmute::<*const u8, *const i8>}, def_id: DefId(2:1760 ~ core[480a]::intrinsics::{extern#1}::transmute), substs: [*const u8, *const i8], is_foreign: true })
error: internal compiler error: compiler/rustc_middle/src/ty/instance.rs:321:17: Instance::mono: DefId(2:1760 ~ core[480a]::intrinsics::{extern#1}::transmute) has type parameters

thread 'rustc' panicked at 'Box<dyn Any>', /rustc/d394408fb38c4de61f765a3ed5189d2731a1da91/compiler/rustc_errors/src/lib.rs:1392:9
stack backtrace:
   0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
   1: std::panic::panic_any::<rustc_errors::ExplicitBug>
   2: <rustc_errors::HandlerInner>::bug::<&alloc::string::String>
   3: <rustc_errors::Handler>::bug::<&alloc::string::String>
   4: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, ()>::{closure#0}, ()>
   5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
   6: rustc_middle::util::bug::bug_fmt
   7: <rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg>>::fill_item::<<rustc_middle::ty::instance::Instance>::mono::{closure#0}>
   8: <rustc_middle::ty::list::List<rustc_middle::ty::subst::GenericArg>>::for_item::<<rustc_middle::ty::instance::Instance>::mono::{closure#0}>
   9: <rustc_middle::ty::instance::Instance>::mono
  10: c2rust_analyze::context::GlobalAnalysisCtxt::known_fn
             at ./src/context.rs:699:43
  11: c2rust_analyze::dataflow::type_check::TypeChecker::visit_call
             at ./src/dataflow/type_check.rs:403:19

transmute is declared in an extern block, but has type parameters, which seems to be confusing our attempt to get its symbol name for checking against known libc functions. We should probably just exclude Abi::RustIntrinsic extern fns from the normal known_fn checking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants