Skip to content

sizeof crash in vtable check for external crate #259

@avanhatt

Description

@avanhatt

When trying to compile vmm-sys-util with RMC, we see the following crash in the new vtable size check code:

vmm-sys-util (master) $ RUST_BACKTRACE=1 RUSTFLAGS="-Z trim-diagnostic-paths=no -Z codegen-backend=gotoc --cfg=rmc" RUSTC=rmc-rustc cargo build --target x86_64-unknown-linux-gnu -j 1
    Updating crates.io index
  Downloaded libc v0.2.97
  Downloaded 1 crate (517.7 KB) in 0.41s
   Compiling bitflags v1.2.1
   Compiling libc v0.2.97
   Compiling vmm-sys-util v0.8.0 (/home/ubuntu/vmm-sys-util)
thread 'rustc' panicked at 'internal error: entered unreachable code: Doesn't have a sizeof', compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/typ.rs:258:28
stack backtrace:
   0: rust_begin_unwind
             at /home/ubuntu/rmc/library/std/src/panicking.rs:515:5
   1: core::panicking::panic_fmt
             at /home/ubuntu/rmc/library/core/src/panicking.rs:92:14
   2: rustc_codegen_llvm::gotoc::cbmc::goto_program::typ::Type::sizeof_in_bits
   3: rustc_codegen_llvm::gotoc::cbmc::goto_program::typ::Type::sizeof
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/typ.rs:239:20
   4: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::check_vtable_size
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs:779:28
   5: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_vtable::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs:827:35
   6: rustc_codegen_llvm::gotoc::metadata::GotocCtx::ensure_global_var
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/metadata.rs:203:33
   7: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_vtable
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs:817:9
   8: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::cast_sized_pointer_to_trait_fat_pointer
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs:983:26
   9: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::cast_sized_pointer_to_fat_pointer
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs:926:13
  10: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::cast_sized_expr_to_unsized_expr
  11: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_pointer_cast
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs:659:37
  12: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_rvalue
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs:390:17
  13: rustc_codegen_llvm::gotoc::statement::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_statement
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/statement.rs:437:60
  14: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_block
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:60:32
  15: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_function::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:147:71
  16: core::iter::traits::iterator::Iterator::for_each::call::{{closure}}
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:733:29
  17: core::iter::adapters::map::map_fold::{{closure}}
             at /home/ubuntu/rmc/library/core/src/iter/adapters/map.rs:82:21
  18: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold::enumerate::{{closure}}
             at /home/ubuntu/rmc/library/core/src/iter/adapters/enumerate.rs:104:27
  19: core::iter::traits::iterator::Iterator::fold
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:2153:21
  20: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold
             at /home/ubuntu/rmc/library/core/src/iter/adapters/enumerate.rs:110:9
  21: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
             at /home/ubuntu/rmc/library/core/src/iter/adapters/map.rs:122:9
  22: core::iter::traits::iterator::Iterator::for_each
             at /home/ubuntu/rmc/library/core/src/iter/traits/iterator.rs:736:9
  23: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_function
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:147:13
  24: <rustc_codegen_llvm::gotoc::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
             at /home/ubuntu/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:318:47
  25: rustc_interface::passes::start_codegen::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:1060:9
  26: rustc_data_structures::profiling::VerboseTimingGuard::run
             at /home/ubuntu/rmc/compiler/rustc_data_structures/src/profiling.rs:573:9
  27: rustc_session::utils::<impl rustc_session::session::Session>::time
             at /home/ubuntu/rmc/compiler/rustc_session/src/utils.rs:16:9
  28: rustc_interface::passes::start_codegen
             at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:1059:19
  29: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:295:20
  30: rustc_interface::passes::QueryContext::enter::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:799:42
  31: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_middle/src/ty/context.rs:1744:50
  32: rustc_middle::ty::context::tls::set_tlv
             at /home/ubuntu/rmc/compiler/rustc_middle/src/ty/context.rs:1728:9
  33: rustc_middle::ty::context::tls::enter_context
             at /home/ubuntu/rmc/compiler/rustc_middle/src/ty/context.rs:1744:9
  34: rustc_interface::passes::QueryContext::enter
             at /home/ubuntu/rmc/compiler/rustc_interface/src/passes.rs:799:9
  35: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:286:13
  36: rustc_interface::queries::Query<T>::compute
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:40:28
  37: rustc_interface::queries::Queries::ongoing_codegen
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:284:9
  38: rustc_driver::run_compiler::{{closure}}::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_driver/src/lib.rs:414:13
  39: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
             at /home/ubuntu/rmc/compiler/rustc_interface/src/queries.rs:435:19
  40: rustc_driver::run_compiler::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_driver/src/lib.rs:313:22
  41: rustc_interface::interface::create_compiler_and_run::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/interface.rs:208:13
  42: rustc_span::with_source_map
             at /home/ubuntu/rmc/compiler/rustc_span/src/lib.rs:873:5
  43: rustc_interface::interface::create_compiler_and_run
             at /home/ubuntu/rmc/compiler/rustc_interface/src/interface.rs:202:5
  44: rustc_interface::interface::run_compiler::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/interface.rs:224:12
  45: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/util.rs:158:13
  46: scoped_tls::ScopedKey<T>::set
             at /home/ubuntu/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
  47: rustc_span::with_session_globals
             at /home/ubuntu/rmc/compiler/rustc_span/src/lib.rs:104:5
  48: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/util.rs:156:9
  49: rustc_interface::util::scoped_thread::{{closure}}
             at /home/ubuntu/rmc/compiler/rustc_interface/src/util.rs:131:24
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

Metadata

Metadata

Assignees

Labels

[C] BugThis is a bug. Something isn't working.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions