Skip to content

Compiler panic during build of dispatch crate #71612

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
solarretrace opened this issue Apr 27, 2020 · 11 comments · Fixed by #71751
Closed

Compiler panic during build of dispatch crate #71612

solarretrace opened this issue Apr 27, 2020 · 11 comments · Fixed by #71751
Assignees
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections O-ios Operating system: iOS O-macos Operating system: macOS P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@solarretrace
Copy link

solarretrace commented Apr 27, 2020

I tried this code:

Tried to build the dispatch crate.

I expected to see this happen: Successful build.
Instead, this happened: Compiler panic.

Meta

rustc --version --verbose:
rustc 1.45.0-nightly (e83f756 2020-04-26)
binary: rustc
commit-hash: e83f756
commit-date: 2020-04-26
host: x86_64-apple-darwin
release: 1.45.0-nightly
LLVM version: 9.0

Backtrace:

error: internal compiler error: src/librustc_mir/interpret/validity.rs:396: Unexpected error during ptr inbounds test: cannot read from foreign (extern) static DefId(0:40 ~ dispatch[6e69]::ffi[0]::[0]::_dispatch_queue_attr_concurrent[0])

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:904:9
stack backtrace:
   0:        0x1100d19df - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h5e3a63e7985407d7
   1:        0x11010b7ee - core::fmt::write::h26bd57c1fd6e9c98
   2:        0x1100c2977 - std::io::Write::write_fmt::h1b039c1010aa04fe
   3:        0x1100d64fa - std::panicking::default_hook::{{closure}}::h7596190ab59d75d5
   4:        0x1100d623c - std::panicking::default_hook::h8a07383816b1a388
   5:        0x114198848 - rustc_driver::report_ice::h296b79ffcf51ce3e
   6:        0x1100d6c15 - std::panicking::rust_panic_with_hook::h0bcea39f2cca3a4b
   7:        0x118234b96 - std::panicking::begin_panic::h66e22c23a1549a6e
   8:        0x117e1cfb7 - rustc_errors::HandlerInner::bug::hb332c3c5946e8455
   9:        0x117e1b9a7 - rustc_errors::Handler::bug::hd936ee9ba186a04d
  10:        0x11789ab39 - rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}::head52c037401cd39
  11:        0x11788f3b6 - rustc_middle::ty::context::tls::with_opt::{{closure}}::h1175b0b6ce73192f
  12:        0x11788f33c - rustc_middle::ty::context::tls::with_opt::hab77656c6808d61d
  13:        0x11789aa48 - rustc_middle::util::bug::opt_span_bug_fmt::he5e4627c7adae268
  14:        0x1182152eb - rustc_middle::util::bug::bug_fmt::h3d982ecec1b3b7c7
  15:        0x116b8b5d3 - rustc_mir::interpret::validity::ValidityVisitor<M>::check_safe_pointer::h291a2bee9f7f4cfe
  16:        0x116b8f9bb - rustc_mir::interpret::validity::ValidityVisitor<M>::try_visit_primitive::hb38fb3a8b177cdeb
  17:        0x116cff30f - rustc_mir::interpret::validity::<impl rustc_mir::interpret::eval_context::InterpCx<M>>::validate_operand_internal::h0fd562892c38caa3
  18:        0x116e30f2d - rustc_mir::const_eval::eval_queries::const_eval_validated_provider::h3c9275a9f466ee97
  19:        0x116a40e8e - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_validated>::compute::hcdb7ef1607ca94a8
  20:        0x116b6ffb8 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hc3e13af361aba2b0
  21:        0x116a7ae95 - rustc_query_system::query::plumbing::get_query::h854993e300e4fae1
  22:        0x116e3061a - rustc_mir::const_eval::eval_queries::const_eval_validated_provider::h3c9275a9f466ee97
  23:        0x117cac8e5 - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::const_eval_validated>::compute::hcdb7ef1607ca94a8
  24:        0x117ad5158 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::h6efc840c34b85f25
  25:        0x117ca414a - rustc_query_system::query::plumbing::get_query::hff598a8d50b70459
  26:        0x1179b4411 - rustc_middle::mir::interpret::queries::<impl rustc_middle::ty::context::TyCtxt>::const_eval_poly::h4c0c73d36c3ca2d5
  27:        0x11746dd7e - <rustc_lint::BuiltinCombinedLateLintPass as rustc_lint::passes::LateLintPass>::check_item::ha3b5b1de31baab6d
  28:        0x114469423 - rustc_hir::intravisit::Visitor::visit_nested_item::h864f6dfe5b2dc4d6
  29:        0x11443397d - rustc_hir::intravisit::walk_item::h7bff3cbd983d4c68
  30:        0x11446942e - rustc_hir::intravisit::Visitor::visit_nested_item::h864f6dfe5b2dc4d6
  31:        0x11442ec9d - rustc_hir::intravisit::walk_crate::hcc8023c9ea6fe572
  32:        0x114449a77 - rustc_session::utils::<impl rustc_session::session::Session>::time::h5b6624f93e07a70e
  33:        0x11444c051 - rustc_session::utils::<impl rustc_session::session::Session>::time::hc7d512eb197226d2
  34:        0x1144a0539 - rustc_interface::passes::analysis::{{closure}}::{{closure}}::h84231c11c9470877
  35:        0x114448e8a - rustc_session::utils::<impl rustc_session::session::Session>::time::h3e5c6d62075716bf
  36:        0x1144a042e - rustc_interface::passes::analysis::h4a4e1a01585c6f70
  37:        0x1141acb5a - rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute::h5be5c3012b981eba
  38:        0x1142ea159 - rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl::hd018b5d7bb8cf53c
  39:        0x1141ad888 - rustc_query_system::query::plumbing::get_query::h1a03c197423e6671
  40:        0x11432075c - rustc_middle::ty::context::tls::enter_global::h7257fd220d03bcfb
  41:        0x1142f2fe1 - rustc_interface::interface::run_compiler_in_existing_thread_pool::hb089841313bdad7a
  42:        0x1141a0ed9 - scoped_tls::ScopedKey<T>::set::hd33ab82953a5937b
  43:        0x11419dfa5 - rustc_ast::attr::with_globals::hcb8a41b5f37a8602
  44:        0x1141a692b - std::sys_common::backtrace::__rust_begin_short_backtrace::hacb8026ff037f54c
  45:        0x1142f4ffc - core::ops::function::FnOnce::call_once{{vtable.shim}}::h8428325df99f3681
  46:        0x1100e524d - std::sys::unix::thread::Thread::new::thread_start::h41525d65c59f0a79
  47:     0x7fff6a6f5e65 - _ZL12preoptimized

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 (e83f75634 2020-04-26) running on x86_64-apple-darwin

note: compiler flags: -C opt-level=3 -C bitcode-in-rlib=no -C codegen-units=1 -C debuginfo=2 -C overflow-checks=on --crate-type lib

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

query stack during panic:
#0 [const_eval_validated] const-evaluating + checking `ffi::DISPATCH_QUEUE_CONCURRENT`
#1 [const_eval_validated] const-evaluating + checking `ffi::DISPATCH_QUEUE_CONCURRENT`
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `dispatch`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
@jonas-schievink jonas-schievink added A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-prioritize Issue: Indicates that prioritization has been requested for this issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example labels Apr 27, 2020
@LeSeulArtichaut
Copy link
Contributor

cargo-bisect-rustc finds the resgression in #71566

searched nightlies: from nightly-2020-04-26 to nightly-2020-04-27
regressed nightly: nightly-2020-04-27
searched commits: from 0862458 to e83f756
regressed commit: b592b37

@LeSeulArtichaut LeSeulArtichaut added regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. and removed E-needs-bisection Call for participation: This issue needs bisection: https://github.com/rust-lang/cargo-bisect-rustc labels Apr 27, 2020
@GabrielMajeri
Copy link
Contributor

GabrielMajeri commented Apr 27, 2020

We've seen this on gfx-rs CI.

It seems to apply only to nightly when targeting Mac OS or iOS. The same nightly on Linux does not cause an ICE.

@LeSeulArtichaut LeSeulArtichaut added O-ios Operating system: iOS O-macos Operating system: macOS labels Apr 27, 2020
@jonas-schievink
Copy link
Contributor

Presumably due to #71140? cc @oli-obk

It looks iOS-specific because dispatch wraps an iOS-specific API. Would be good to find an MCVE.

@spastorino
Copy link
Member

Assigning P-high as discussed as part of the Prioritization Working Group process and removing I-prioritize.

@spastorino spastorino added P-high High priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Apr 27, 2020
@LeSeulArtichaut
Copy link
Contributor

@rustbot ping cleanup

Let’s try to find an MVCE and find out if this ICE only appears on MacOS.

@rustbot
Copy link
Collaborator

rustbot commented Apr 27, 2020

Hey Cleanup Crew ICE-breakers! This bug has been identified as a good
"Cleanup ICE-breaking candidate". In case it's useful, here are some
instructions for tackling these sorts of bugs. Maybe take a look?
Thanks! <3

cc @AminArria @chrissimpkins @contrun @DutchGhost @elshize @ethanboxx @h-michael @HallerPatrick @hdhoang @hellow554 @imtsuki @jakevossen5 @kanru @KarlK90 @LeSeulArtichaut @MAdrianMattocks @matheus-consoli @mental32 @nmccarty @Noah-Kennedy @pard68 @PeytonT @pierreN @Redblueflame @RobbieClarken @RobertoSnap @robjtede @SarthakSingh31 @senden9 @shekohex @sinato @spastorino @turboladen @woshilapin @yerke

@rustbot rustbot added the ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections label Apr 27, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Apr 28, 2020

Presumably due to #71140? cc @oli-obk

Huh, curious. I guess we didn't catch it there because crater doesn't run on ios, but also the error is one I would not have expected to come from that PR. That PR should have only caused new cycle errors, nothing else.

@dhardy
Copy link
Contributor

dhardy commented Apr 29, 2020

I think I hit the same error on OSX in the stack_dst crate; check this log.

@jonas-schievink
Copy link
Contributor

Yeah, that's also the dispatch crate causing it

@aloucks
Copy link
Contributor

aloucks commented Apr 29, 2020

I'm seeing the same error, also caused by the dispatch crate on macOS (not iOS):

   Compiling dispatch v0.1.4
error: internal compiler error: src/librustc_mir/interpret/validity.rs:396: Unexpected error during ptr inbounds test: cannot read from foreign (extern) static DefId(0:34 ~ dispatch[dcca]::ffi[0]::[0]::_dispatch_queue_attr_concurrent[0])
##[error]internal compiler error: src/librustc_mir/interpret/validity.rs:396: Unexpected error during ptr inbounds test: cannot read from foreign (extern) static DefId(0:34 ~ dispatch[dcca]::ffi[0]::[0]::_dispatch_queue_attr_concurrent[0])
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:904:9

https://github.com/aloucks/vki/runs/627976394?check_suite_focus=true

@oli-obk oli-obk self-assigned this Apr 30, 2020
@oli-obk
Copy link
Contributor

oli-obk commented May 1, 2020

Minimal repro:

extern "C" {
    static _dispatch_queue_attr_concurrent: ();
}

static DISPATCH_QUEUE_CONCURRENT: &'static () =
    unsafe { &_dispatch_queue_attr_concurrent };

@jonas-schievink jonas-schievink removed the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label May 1, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ ICEBreaker-Cleanup-Crew Helping to "clean up" bugs with minimal examples and bisections O-ios Operating system: iOS O-macos Operating system: macOS P-high High priority regression-from-stable-to-nightly Performance or correctness regression from stable to nightly. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants