Skip to content

Codegen issues in rand crate #111

@nchong-at-aws

Description

@nchong-at-aws

Trying to compile rand crate:

git clone https://github.com/rust-random/rand.git
cd rand
RUST_BACKTRACE=1 RUSTFLAGS="-Z trim-diagnostic-paths=no -Z codegen-backend=gotoc" RUSTC_LOG="rustc_codegen_llvm::gotoc" RUSTC=rmc-rustc cargo build --verbose --target x86_64-unknown-linux-gnu -j 1 

crashes RMC:

thread 'rustc' panicked at 'Can't cast

Expr { value: Symbol { identifier: "_ZN80_$LT$dyn$u20$std..error..Error$u2b$core..marker..Send$u2b$core..marker..Sync$GT$12downcast_ref17h06378e08c6fa74f7E::1::var_3" }, typ: StructTag("tag-dyn std::error::Error + core::marker::Send + core::marker::Sync"), location: None }

Pointer { typ: Empty }', compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/expr.rs:409:9
stack backtrace:
   0: rust_begin_unwind
             at /local/home/ncchong/rmc/library/std/src/panicking.rs:493:5
   1: std::panicking::begin_panic_fmt
             at /local/home/ncchong/rmc/library/std/src/panicking.rs:435:5
   2: rustc_codegen_llvm::gotoc::cbmc::goto_program::expr::Expr::cast_to
             at /local/home/ncchong/rmc/compiler/rustc_codegen_llvm/src/gotoc/cbmc/goto_program/expr.rs:409:9
   3: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::cast_sized_pointer_to_trait_fat_pointer
             at /local/home/ncchong/rmc/compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs:962:33
   4: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::cast_sized_pointer_to_fat_pointer
             at /local/home/ncchong/rmc/compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs:907:13
   5: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::cast_sized_expr_to_unsized_expr
   6: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_pointer_cast
             at /local/home/ncchong/rmc/compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs:653:37
   7: rustc_codegen_llvm::gotoc::rvalue::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_rvalue
             at /local/home/ncchong/rmc/compiler/rustc_codegen_llvm/src/gotoc/rvalue.rs:384:17
   8: rustc_codegen_llvm::gotoc::statement::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_statement
             at /local/home/ncchong/rmc/compiler/rustc_codegen_llvm/src/gotoc/statement.rs:412:60
   9: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_block
             at /local/home/ncchong/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:59:32
  10: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_function::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:113:71
  11: core::iter::traits::iterator::Iterator::for_each::call::{{closure}}
             at /local/home/ncchong/rmc/library/core/src/iter/traits/iterator.rs:773:29
  12: core::iter::adapters::map::map_fold::{{closure}}
             at /local/home/ncchong/rmc/library/core/src/iter/adapters/map.rs:82:21
  13: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold::enumerate::{{closure}}
             at /local/home/ncchong/rmc/library/core/src/iter/adapters/enumerate.rs:104:27
  14: core::iter::traits::iterator::Iterator::fold
             at /local/home/ncchong/rmc/library/core/src/iter/traits/iterator.rs:2147:21
  15: <core::iter::adapters::enumerate::Enumerate<I> as core::iter::traits::iterator::Iterator>::fold
             at /local/home/ncchong/rmc/library/core/src/iter/adapters/enumerate.rs:110:9
  16: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
             at /local/home/ncchong/rmc/library/core/src/iter/adapters/map.rs:122:9
  17: core::iter::traits::iterator::Iterator::for_each
             at /local/home/ncchong/rmc/library/core/src/iter/traits/iterator.rs:776:9
  18: rustc_codegen_llvm::gotoc::<impl rustc_codegen_llvm::gotoc::metadata::GotocCtx>::codegen_function
             at /local/home/ncchong/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:113:13
  19: <rustc_codegen_llvm::gotoc::GotocCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
             at /local/home/ncchong/rmc/compiler/rustc_codegen_llvm/src/gotoc/mod.rs:281:47
  20: rustc_interface::passes::start_codegen::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/passes.rs:1021:9
  21: rustc_data_structures::profiling::VerboseTimingGuard::run
             at /local/home/ncchong/rmc/compiler/rustc_data_structures/src/profiling.rs:573:9
  22: rustc_session::utils::<impl rustc_session::session::Session>::time
             at /local/home/ncchong/rmc/compiler/rustc_session/src/utils.rs:16:9
  23: rustc_interface::passes::start_codegen
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/passes.rs:1020:19
  24: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/queries.rs:296:20
  25: rustc_interface::passes::QueryContext::enter::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/passes.rs:755:42
  26: rustc_middle::ty::context::tls::enter_context::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_middle/src/ty/context.rs:1733:50
  27: rustc_middle::ty::context::tls::set_tlv
             at /local/home/ncchong/rmc/compiler/rustc_middle/src/ty/context.rs:1717:9
  28: rustc_middle::ty::context::tls::enter_context
             at /local/home/ncchong/rmc/compiler/rustc_middle/src/ty/context.rs:1733:9
  29: rustc_interface::passes::QueryContext::enter
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/passes.rs:755:9
  30: rustc_interface::queries::Queries::ongoing_codegen::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/queries.rs:287:13
  31: rustc_interface::queries::Query<T>::compute
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/queries.rs:40:28
  32: rustc_interface::queries::Queries::ongoing_codegen
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/queries.rs:285:9
  33: rustc_driver::run_compiler::{{closure}}::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_driver/src/lib.rs:442:13
  34: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/queries.rs:432:19
  35: rustc_driver::run_compiler::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_driver/src/lib.rs:337:22
  36: rustc_interface::interface::create_compiler_and_run::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/interface.rs:208:13
  37: rustc_span::with_source_map
             at /local/home/ncchong/rmc/compiler/rustc_span/src/lib.rs:787:5
  38: rustc_interface::interface::create_compiler_and_run
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/interface.rs:202:5
  39: rustc_interface::interface::run_compiler::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/interface.rs:224:12
  40: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/util.rs:155:13
  41: scoped_tls::ScopedKey<T>::set
             at /home/ncchong/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-1.0.0/src/lib.rs:137:9
  42: rustc_span::with_session_globals
             at /local/home/ncchong/rmc/compiler/rustc_span/src/lib.rs:104:5
  43: rustc_interface::util::setup_callbacks_and_run_in_thread_pool_with_globals::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/util.rs:153:9
  44: rustc_interface::util::scoped_thread::{{closure}}
             at /local/home/ncchong/rmc/compiler/rustc_interface/src/util.rs:128:24

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