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

ICE: thread 'rustc' panicked at 'call to rustc_peek should be preceded by assignment to temporary holding its argument', compiler/rustc_mir/src/transform/rustc_peek.rs #83461

Closed
chengniansun opened this issue Mar 25, 2021 · 2 comments
Labels
C-bug Category: This is a bug. F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@chengniansun
Copy link

Code

#![feature(core_intrinsics, rustc_attrs)]
use std::intrinsics::rustc_peek;
struct S;
#[rustc_mir(rustc_peek_definite_init)]
fn foo(z: S) {
    let ret;
    rustc_peek(rustc_peek(z));
    ret
}

Meta

rustc --version --verbose:

rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
binary: rustc
commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597
commit-date: 2021-03-24
host: x86_64-unknown-linux-gnu
release: 1.53.0-nightly
LLVM version: 12.0.0

Error output

thread 'rustc' panicked at 'call to rustc_peek should be preceded by assignment to temporary holding its argument', compiler/rustc_mir/src/transform/rustc_peek.rs:132:14
note: run with `RUST_BACKTRACE=1` environment variable to display a 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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.53.0-nightly (07e0e2ec2 2021-03-24) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type staticlib

query stack during panic:
#0 [mir_const] processing MIR for `foo`
#1 [mir_promoted] processing `foo`
end of query stack
Backtrace

thread 'rustc' panicked at 'call to rustc_peek should be preceded by assignment to temporary holding its argument', compiler/rustc_mir/src/transform/rustc_peek.rs:132:14
stack backtrace:
   0: rust_begin_unwind
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/std/src/panicking.rs:493:5
   1: core::panicking::panic_fmt
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/panicking.rs:92:14
   2: core::option::expect_failed
             at /rustc/07e0e2ec268c140e607e1ac7f49f145612d0f597/library/core/src/option.rs:1321:5
   3: <rustc_mir::transform::rustc_peek::SanityCheck as rustc_mir::transform::MirPass>::run_pass
   4: rustc_mir::transform::run_passes
   5: rustc_mir::transform::mir_const
   6: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
   7: rustc_query_system::query::plumbing::force_query_with_job
   8: rustc_query_system::query::plumbing::get_query_impl
   9: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_const
  10: rustc_mir::transform::mir_promoted
  11: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  12: rustc_query_system::query::plumbing::force_query_with_job
  13: rustc_query_system::query::plumbing::get_query_impl
  14: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_promoted
  15: rustc_mir::borrow_check::mir_borrowck
  16: core::ops::function::FnOnce::call_once
  17: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  18: rustc_query_system::query::plumbing::force_query_with_job
  19: rustc_query_system::query::plumbing::get_query_impl
  20: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::mir_borrowck
  21: rustc_middle::ty::<impl rustc_middle::ty::context::TyCtxt>::par_body_owners
  22: rustc_interface::passes::analysis
  23: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  24: rustc_data_structures::stack::ensure_sufficient_stack
  25: rustc_query_system::query::plumbing::force_query_with_job
  26: rustc_query_system::query::plumbing::get_query_impl
  27: <rustc_query_impl::Queries as rustc_middle::ty::query::QueryEngine>::analysis
  28: rustc_interface::passes::QueryContext::enter
  29: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  30: rustc_span::with_source_map
  31: rustc_interface::interface::create_compiler_and_run
  32: scoped_tls::ScopedKey<T>::set
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.53.0-nightly (07e0e2ec2 2021-03-24) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type staticlib

query stack during panic:
#0 [mir_const] processing MIR for `foo`
#1 [mir_promoted] processing `foo`
#2 [mir_borrowck] borrow-checking `foo`
#3 [analysis] running analysis passes on this crate
end of query stack

@chengniansun chengniansun added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Mar 25, 2021
fanninpm added a commit to fanninpm/glacier that referenced this issue Mar 26, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Mar 27, 2021
@jruderman
Copy link
Contributor

I hit this in my fuzzing as well.

Code

#![feature(core_intrinsics, rustc_attrs)]

use std::intrinsics::rustc_peek;

fn k() {}

#[rustc_mir(rustc_peek_definite_init,stop_after_dataflow)]
fn foo() {
    rustc_peek(k());
}

fn main() {}

Error output

thread 'rustc' panicked at 'call to rustc_peek should be preceded by assignment to temporary holding its argument', compiler/rustc_mir_dataflow/src/rustc_peek.rs:117

Backtrace
stack backtrace:
   0:        0x10d5c6496 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h388d18e35423230a
   1:        0x10d624e0a - core::fmt::write::hae057d6b754f72d8
   2:        0x10d5b883c - std::io::Write::write_fmt::h442179bd60267d8e
   3:        0x10d5c627a - std::sys_common::backtrace::print::habab5a5c263740eb
   4:        0x10d5c95c3 - std::panicking::default_hook::{{closure}}::h831e1cc678bd888c
   5:        0x10d5c9318 - std::panicking::default_hook::h8f0af5f1b913f212
   6:        0x115c6ff8d - rustc_driver[c28c713964f6db5f]::DEFAULT_HOOK::{closure#0}::{closure#0}
   7:        0x10d5c9da7 - std::panicking::rust_panic_with_hook::h20ce9404b4438d87
   8:        0x10d5c9b54 - std::panicking::begin_panic_handler::{{closure}}::h153e2afe83634090
   9:        0x10d5c6938 - std::sys_common::backtrace::__rust_end_short_backtrace::hb594464367a2d0dc
  10:        0x10d5c981d - _rust_begin_unwind
  11:        0x10d6513e3 - core::panicking::panic_fmt::h07c9fba3a925cee1
  12:        0x10d62198b - core::panicking::panic_display::hcfed2b33fafb0908
  13:        0x10d62193c - core::panicking::panic_str::hf710a6722843e2d7
  14:        0x10d6513a9 - core::option::expect_failed::h6c202761b9020bfc
  15:        0x119377b3a - <rustc_mir_dataflow[294d552b03b9f85c]::rustc_peek::SanityCheck as rustc_middle[b06de2f7571e6fcc]::mir::MirPass>::run_pass
  16:        0x1187e1c39 - rustc_mir_transform[1ad4961f1785d654]::pass_manager::run_passes_inner
  17:        0x11891a55a - rustc_mir_transform[1ad4961f1785d654]::mir_const
  18:        0x11942e39d - rustc_query_system[727f66452900dcdf]::query::plumbing::try_execute_query::<rustc_query_impl[e6bb220d622b6c4e]::plumbing::QueryCtxt, rustc_query_system[727f66452900dcdf]::query::caches::DefaultCache<rustc_middle[b06de2f7571e6fcc]::ty::WithOptConstParam<rustc_span[a499e2c93bb8a38c]::def_id::LocalDefId>, &rustc_data_structures[efdbdd24b9867b6]::steal::Steal<rustc_middle[b06de2f7571e6fcc]::mir::Body>>>
  19:        0x11956b76d - rustc_query_system[727f66452900dcdf]::query::plumbing::get_query::<rustc_query_impl[e6bb220d622b6c4e]::queries::mir_const, rustc_query_impl[e6bb220d622b6c4e]::plumbing::QueryCtxt>
  20:        0x119642477 - <rustc_query_impl[e6bb220d622b6c4e]::Queries as rustc_middle[b06de2f7571e6fcc]::ty::query::QueryEngine>::mir_const
  21:        0x11891b453 - rustc_mir_transform[1ad4961f1785d654]::mir_promoted
  22:        0x11942f5a1 - rustc_query_system[727f66452900dcdf]::query::plumbing::try_execute_query::<rustc_query_impl[e6bb220d622b6c4e]::plumbing::QueryCtxt, rustc_query_system[727f66452900dcdf]::query::caches::DefaultCache<rustc_middle[b06de2f7571e6fcc]::ty::WithOptConstParam<rustc_span[a499e2c93bb8a38c]::def_id::LocalDefId>, (&rustc_data_structures[efdbdd24b9867b6]::steal::Steal<rustc_middle[b06de2f7571e6fcc]::mir::Body>, &rustc_data_structures[efdbdd24b9867b6]::steal::Steal<rustc_index[c336d4038c12cec8]::vec::IndexVec<rustc_middle[b06de2f7571e6fcc]::mir::Promoted, rustc_middle[b06de2f7571e6fcc]::mir::Body>>)>>
  23:        0x119555940 - rustc_query_system[727f66452900dcdf]::query::plumbing::get_query::<rustc_query_impl[e6bb220d622b6c4e]::queries::mir_promoted, rustc_query_impl[e6bb220d622b6c4e]::plumbing::QueryCtxt>
  24:        0x119642637 - <rustc_query_impl[e6bb220d622b6c4e]::Queries as rustc_middle[b06de2f7571e6fcc]::ty::query::QueryEngine>::mir_promoted
  25:        0x118fdd61f - rustc_borrowck[e6dd8db3b09abc46]::mir_borrowck
  26:        0x118fb81d5 - <rustc_borrowck[e6dd8db3b09abc46]::provide::{closure#0} as core[af36ead597221bd6]::ops::function::FnOnce<(rustc_middle[b06de2f7571e6fcc]::ty::context::TyCtxt, rustc_span[a499e2c93bb8a38c]::def_id::LocalDefId)>>::call_once
  27:        0x1194e0614 - rustc_query_system[727f66452900dcdf]::query::plumbing::try_execute_query::<rustc_query_impl[e6bb220d622b6c4e]::plumbing::QueryCtxt, rustc_query_system[727f66452900dcdf]::query::caches::VecCache<rustc_span[a499e2c93bb8a38c]::def_id::LocalDefId, &rustc_middle[b06de2f7571e6fcc]::mir::query::BorrowCheckResult>>
  28:        0x1195556a7 - rustc_query_system[727f66452900dcdf]::query::plumbing::get_query::<rustc_query_impl[e6bb220d622b6c4e]::queries::mir_borrowck, rustc_query_impl[e6bb220d622b6c4e]::plumbing::QueryCtxt>
  29:        0x115d846bb - rustc_data_structures[efdbdd24b9867b6]::sync::par_for_each_in::<&[rustc_span[a499e2c93bb8a38c]::def_id::LocalDefId], <rustc_middle[b06de2f7571e6fcc]::hir::map::Map>::par_body_owners<rustc_interface[e8482e30f906f63e]::passes::analysis::{closure#2}::{closure#0}>::{closure#0}>
  30:        0x115cf59e0 - <rustc_session[7e50a26a31d731b]::session::Session>::time::<(), rustc_interface[e8482e30f906f63e]::passes::analysis::{closure#2}>
  31:        0x115d388a3 - rustc_interface[e8482e30f906f63e]::passes::analysis
  32:        0x1194af54b - rustc_query_system[727f66452900dcdf]::query::plumbing::try_execute_query::<rustc_query_impl[e6bb220d622b6c4e]::plumbing::QueryCtxt, rustc_query_system[727f66452900dcdf]::query::caches::DefaultCache<(), core[af36ead597221bd6]::result::Result<(), rustc_errors[31109329a537279e]::ErrorGuaranteed>>>
  33:        0x11956a66d - rustc_query_system[727f66452900dcdf]::query::plumbing::get_query::<rustc_query_impl[e6bb220d622b6c4e]::queries::analysis, rustc_query_impl[e6bb220d622b6c4e]::plumbing::QueryCtxt>
  34:        0x115c02077 - <rustc_interface[e8482e30f906f63e]::passes::QueryContext>::enter::<rustc_driver[c28c713964f6db5f]::run_compiler::{closure#1}::{closure#2}::{closure#2}, core[af36ead597221bd6]::result::Result<(), rustc_errors[31109329a537279e]::ErrorGuaranteed>>
  35:        0x115c48525 - <rustc_interface[e8482e30f906f63e]::interface::Compiler>::enter::<rustc_driver[c28c713964f6db5f]::run_compiler::{closure#1}::{closure#2}, core[af36ead597221bd6]::result::Result<core[af36ead597221bd6]::option::Option<rustc_interface[e8482e30f906f63e]::queries::Linker>, rustc_errors[31109329a537279e]::ErrorGuaranteed>>
  36:        0x115be479d - rustc_span[a499e2c93bb8a38c]::with_source_map::<core[af36ead597221bd6]::result::Result<(), rustc_errors[31109329a537279e]::ErrorGuaranteed>, rustc_interface[e8482e30f906f63e]::interface::run_compiler<core[af36ead597221bd6]::result::Result<(), rustc_errors[31109329a537279e]::ErrorGuaranteed>, rustc_driver[c28c713964f6db5f]::run_compiler::{closure#1}>::{closure#0}::{closure#0}>
  37:        0x115c3b43d - <scoped_tls[826d51480f7487f1]::ScopedKey<rustc_span[a499e2c93bb8a38c]::SessionGlobals>>::set::<rustc_interface[e8482e30f906f63e]::interface::run_compiler<core[af36ead597221bd6]::result::Result<(), rustc_errors[31109329a537279e]::ErrorGuaranteed>, rustc_driver[c28c713964f6db5f]::run_compiler::{closure#1}>::{closure#0}, core[af36ead597221bd6]::result::Result<(), rustc_errors[31109329a537279e]::ErrorGuaranteed>>
  38:        0x115c0a99a - std[c99b25d27e8b6be0]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[e8482e30f906f63e]::util::run_in_thread_pool_with_globals<rustc_interface[e8482e30f906f63e]::interface::run_compiler<core[af36ead597221bd6]::result::Result<(), rustc_errors[31109329a537279e]::ErrorGuaranteed>, rustc_driver[c28c713964f6db5f]::run_compiler::{closure#1}>::{closure#0}, core[af36ead597221bd6]::result::Result<(), rustc_errors[31109329a537279e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[af36ead597221bd6]::result::Result<(), rustc_errors[31109329a537279e]::ErrorGuaranteed>>
  39:        0x115beac95 - <<std[c99b25d27e8b6be0]::thread::Builder>::spawn_unchecked_<rustc_interface[e8482e30f906f63e]::util::run_in_thread_pool_with_globals<rustc_interface[e8482e30f906f63e]::interface::run_compiler<core[af36ead597221bd6]::result::Result<(), rustc_errors[31109329a537279e]::ErrorGuaranteed>, rustc_driver[c28c713964f6db5f]::run_compiler::{closure#1}>::{closure#0}, core[af36ead597221bd6]::result::Result<(), rustc_errors[31109329a537279e]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[af36ead597221bd6]::result::Result<(), rustc_errors[31109329a537279e]::ErrorGuaranteed>>::{closure#1} as core[af36ead597221bd6]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  40:        0x10d5d2f97 - std::sys::unix::thread::Thread::new::thread_start::ha16bf32d64a7247b
  41:     0x7ff807a764e1 - __pthread_start

Regression

Regression in nightly-2019-10-03, likely from #64980, which added this expect call (@ecstatic-morse)

Version

rustc 1.67.0-nightly (b3bc6bf31 2022-11-24)
binary: rustc
commit-hash: b3bc6bf31265ac10946a0832092dbcedf9b26805
commit-date: 2022-11-24
host: x86_64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4

@rustbot label +requires-nightly +F-rustc_attrs

@rustbot rustbot added F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. requires-nightly This issue requires a nightly compiler in some way. labels Nov 25, 2022
@workingjubilee
Copy link
Member

Misuse of an intrinsic causing an ICE is expected behavior.

@workingjubilee workingjubilee closed this as not planned Won't fix, can't repro, duplicate, stale Mar 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-rustc_attrs Internal rustc attributes gated on the `#[rustc_attrs]` feature gate. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants