Skip to content

ICE with new asm! macro and incremental compilation #72386

Closed
@macpp

Description

@macpp

Discovered when playing with new asm! macro #69171

How to reproduce

  1. cargo run with following code:
fn main() {
    unsafe {
        asm!("nop")
    }
}
  1. change asm! usage to
asm!("nop",out("invalid_reg")_)

building will result in error, because this is invalid register name ( this is 100% correct)

  1. change back to asm!("nop") (same code as in 1)
    build will result with ICE:
thread 'rustc' panicked at 'missing specialization: `<rustc_middle::ty::query::on_disk_cache::CacheDecoder as SpecializedDecoder<&[rustc_ast::ast::InlineAsmTemplatePiece]>>::specialized_decode` not overridden', /rustc/3a7dfda40a3e798bf086bd58cc7e5e09deb808b5/src/libstd/macros.rs:16:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.tiyicn.workers.dev-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/libunwind.rs:86
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.tiyicn.workers.dev-1ecc6299db9ec823/backtrace-0.3.46/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:78
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:59
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1069
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1537
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:62
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:198
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:218
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:490
  12: rust_begin_unwind
             at src/libstd/panicking.rs:388
  13: std::panicking::begin_panic_fmt
             at src/libstd/panicking.rs:342
  14: <E as serialize::serialize::SpecializationError>::not_found
  15: <rustc_middle::mir::Terminator as serialize::serialize::Decodable>::decode
  16: serialize::serialize::Decoder::read_option
  17: <rustc_middle::mir::BasicBlockData as serialize::serialize::Decodable>::decode
  18: serialize::serialize::Decoder::read_seq
  19: <rustc_middle::mir::Body as serialize::serialize::Decodable>::decode
  20: rustc_middle::ty::query::on_disk_cache::OnDiskCache::try_load_query_result
  21: rustc_middle::query::<impl rustc_query_system::query::config::QueryDescription<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::optimized_mir>::try_load_from_disk
  22: rustc_query_system::query::plumbing::load_from_disk_and_cache_in_memory
  23: rustc_data_structures::stack::ensure_sufficient_stack
  24: rustc_query_system::query::plumbing::get_query_impl
  25: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::instance_mir
  26: rustc_mir::monomorphize::collector::collect_neighbours
  27: rustc_data_structures::stack::ensure_sufficient_stack
  28: rustc_mir::monomorphize::collector::collect_items_rec
  29: rustc_session::utils::<impl rustc_session::session::Session>::time
  30: rustc_mir::monomorphize::collector::collect_crate_mono_items
  31: rustc_mir::monomorphize::partitioning::collect_and_partition_mono_items
  32: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::collect_and_partition_mono_items>::compute
  33: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  34: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  35: rustc_data_structures::stack::ensure_sufficient_stack
  36: rustc_query_system::query::plumbing::get_query_impl
  37: rustc_codegen_ssa::base::codegen_crate
  38: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_ssa::traits::backend::CodegenBackend>::codegen_crate
  39: rustc_session::utils::<impl rustc_session::session::Session>::time
  40: rustc_interface::passes::start_codegen
  41: rustc_middle::ty::context::tls::enter_global
  42: rustc_interface::queries::Queries::ongoing_codegen
  43: rustc_interface::interface::run_compiler_in_existing_thread_pool
  44: scoped_tls::ScopedKey<T>::set
  45: rustc_ast::attr::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: internal compiler error: unexpected panic

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.45.0-nightly (3a7dfda40 2020-05-19) running on x86_64-unknown-linux-gnu

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type bin

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

query stack during panic:
#0 [optimized_mir] processing `main`
#1 [collect_and_partition_mono_items] collect_and_partition_mono_items
end of query stack
error: could not compile `test_asm`.

Workarounds

  • disable incremental compilation
  • cargo clean

Meta

rustc --version --verbose:

rustc 1.45.0-nightly (3a7dfda40 2020-05-19)
binary: rustc
commit-hash: 3a7dfda40a3e798bf086bd58cc7e5e09deb808b5
commit-date: 2020-05-19
host: x86_64-unknown-linux-gnu
release: 1.45.0-nightly
LLVM version: 9.0

also fails on x86_64-pc-windows-gnu

Activity

added
A-incr-compArea: Incremental compilation
A-inline-assemblyArea: Inline assembly (`asm!(…)`)
F-asm`#![feature(asm)]` (not `llvm_asm`)
T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
on May 20, 2020
macpp

macpp commented on May 20, 2020

@macpp
Author
added a commit that references this issue on May 20, 2020
969da62
Aaron1011

Aaron1011 commented on May 20, 2020

@Aaron1011
Member

@Amanieu: It looks like you're missing the decode modifier here:

[] asm_operand: rustc_hir::InlineAsmOperand<$tcx>,
[] asm_template: rustc_ast::ast::InlineAsmTemplatePiece,

Amanieu

Amanieu commented on May 20, 2020

@Amanieu
Member

That doesn't seem to work since InlineAsmTemplatePiece isn't Copy.

Aaron1011

Aaron1011 commented on May 20, 2020

@Aaron1011
Member

@Amanieu: It looks like it's nececessary to declare [] asm_operand: rustc_hir::InlineAsmOperand<$tcx> in both librustc_hir/arena.rs and librustc_middle/arena.rs. The error is caused by the wrong ArenaAllocatable trait being used (there are two - one for each crate that calls declare_arena.

Do you want to use your apporach, or should I open a PR with the arena changes?

11 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-incr-compArea: Incremental compilationA-inline-assemblyArea: Inline assembly (`asm!(…)`)A-specializationArea: Trait impl specializationC-bugCategory: This is a bug.F-asm`#![feature(asm)]` (not `llvm_asm`)I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Participants

      @Amanieu@Aaron1011@jonas-schievink@macpp@AaronKutch

      Issue actions

        ICE with new asm! macro and incremental compilation · Issue #72386 · rust-lang/rust