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

thread 'rustc' panicked at 'Box<Any>' #41210

Closed
sunjay opened this issue Apr 10, 2017 · 3 comments
Closed

thread 'rustc' panicked at 'Box<Any>' #41210

sunjay opened this issue Apr 10, 2017 · 3 comments
Labels
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.

Comments

@sunjay
Copy link
Member

sunjay commented Apr 10, 2017

I was in the middle of making a big changes to some code when this panic occurred. I was expecting a lot of compiler errors but got a compiler panic instead! 😨

Version Info

$ rustc --version --verbose
rustc 1.16.0 (30cf806ef 2017-03-10)
binary: rustc
commit-hash: 30cf806ef8881c41821fbd43e5cf3699c5290c16
commit-date: 2017-03-10
host: x86_64-unknown-linux-gnu
release: 1.16.0
LLVM version: 3.9
$ cargo --version
cargo-0.17.0-nightly (f9e5481 2017-03-03)

I ran the build with cargo +nightly test and the panic still occurred.

Compiler Output

Run cargo test to get this.

Here's the full output with RUST_BACKTRACE=1:

error[E0412]: cannot find type `ArraySize` in this scope
  --> src/operations/item_type.rs:19:22
   |
19 |         size: Option<ArraySize>,
   |                      ^^^^^^^^^ not found in this scope
   |
   = help: possible candidate is found in another module, you can import it into scope:
             `use operations::scope::ArraySize;`

error[E0412]: cannot find type `TypeId` in this scope
  --> src/core/io/stdio.rs:16:50
   |
16 | fn define_stdin(scope: &mut ScopeStack, u8_type: TypeId) {
   |                                                  ^^^^^^ not found in this scope
   |
   = help: possible candidates are found in other modules, you can import them into scope:
             `use operations::scope::TypeId;`
             `use std::any::TypeId;`

error[E0412]: cannot find type `ArraySize` in this scope
  --> src/operations/item_type.rs:19:22
   |
19 |         size: Option<ArraySize>,
   |                      ^^^^^^^^^ not found in this scope
   |
   = help: possible candidate is found in another module, you can import it into scope:
             `use operations::scope::ArraySize;`

error[E0412]: cannot find type `TypeId` in this scope
  --> src/core/io/stdio.rs:16:50
   |
16 | fn define_stdin(scope: &mut ScopeStack, u8_type: TypeId) {
   |                                                  ^^^^^^ not found in this scope
   |
   = help: possible candidates are found in other modules, you can import them into scope:
             `use operations::scope::TypeId;`
             `use std::any::TypeId;`

error: no associated item named `Type` found for type `operations::scope::ScopeItem` in the current scope
  --> src/operations/type_definition.rs:15:13
   |
15 |             ScopeItem::Type(id) => Ok(id),
   |             ^^^^^^^^^^^^^^^^^^^

error[E0223]: ambiguous associated type
  --> src/operations/type_definition.rs:16:13
   |
16 |             ScopeItem::BuiltInFunction {id, ..} => Ok(id),
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type
   |
   = note: specify the type using the syntax `<operations::scope::ScopeItem as Trait>::BuiltInFunction`

error: internal compiler error: /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc/middle/mem_categorization.rs:1175: tuple struct pattern didn't resolve to variant or struct Err
  --> src/operations/type_definition.rs:15:13
   |
15 |             ScopeItem::Type(id) => Ok(id),
   |             ^^^^^^^^^^^^^^^^^^^

error: no associated item named `Type` found for type `operations::scope::ScopeItem` in the current scope
  --> src/operations/type_definition.rs:15:13
   |
15 |             ScopeItem::Type(id) => Ok(id),
   |             ^^^^^^^^^^^^^^^^^^^

error[E0223]: ambiguous associated type
  --> src/operations/type_definition.rs:16:13
   |
16 |             ScopeItem::BuiltInFunction {id, ..} => Ok(id),
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^ ambiguous associated type
   |
   = note: specify the type using the syntax `<operations::scope::ScopeItem as Trait>::BuiltInFunction`

error: internal compiler error: /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc/middle/mem_categorization.rs:1175: tuple struct pattern didn't resolve to variant or struct Err
  --> src/operations/type_definition.rs:15:13
   |
15 |             ScopeItem::Type(id) => Ok(id),
   |             ^^^^^^^^^^^^^^^^^^^

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: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc_errors/lib.rs:375
stack backtrace:
   1:     0x7f862943740c - std::sys::imp::backtrace::tracing::imp::write::hf33ae72d0baa11ed
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x7f86294459ae - std::panicking::default_hook::{{closure}}::h59672b733cc6a455
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:351
   3:     0x7f8629445553 - std::panicking::default_hook::h1670459d2f3f8843
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:361
   4:     0x7f8629445e4b - std::panicking::rust_panic_with_hook::hcf0ddb069e7beee7
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:555
   5:     0x7f86263b79f8 - std::panicking::begin_panic::h7615035f91af0a46
   6:     0x7f8626568165 - rustc::session::opt_span_bug_fmt::{{closure}}::hb8dfe55fdd29ba42
   7:     0x7f8626567c65 - rustc::session::opt_span_bug_fmt::h0cd2e09801797662
   8:     0x7f8626567af4 - rustc::session::span_bug_fmt::hd9d57beec0176564
   9:     0x7f8626522e05 - rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_::hf9ee6cc28f4950bf
  10:     0x7f8626502fe8 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr::h67cf415f4e516db4
  11:     0x7f8626501e41 - rustc::middle::expr_use_visitor::ExprUseVisitor::consume_body::hf960393f75684590
  12:     0x7f8627e09a1c - <rustc_typeck::check::upvar::AdjustBorrowKind<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_fn::hcfd8923185beae25
  13:     0x7f8627da9267 - rustc::hir::intravisit::walk_expr::hb6d0c21c465f62f9
  14:     0x7f8627da8c1e - rustc::hir::intravisit::walk_expr::hb6d0c21c465f62f9
  15:     0x7f8627da8f4e - rustc::hir::intravisit::walk_expr::hb6d0c21c465f62f9
  16:     0x7f8627e08210 - rustc_typeck::check::upvar::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::closure_analyze::h260e6c5912cc14b4
  17:     0x7f8627e386a6 - rustc_typeck::check::check_bare_fn::h9f0916104d636ee0
  18:     0x7f8627e35875 - rustc_typeck::check::check_item_bodies::hd9e8c6a8692f314b
  19:     0x7f8627ea3497 - rustc_typeck::check_crate::h8c159f70d1009b33
  20:     0x7f86297e3cd7 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h040eea107b0d299b
  21:     0x7f86297e06c6 - rustc_driver::driver::phase_3_run_analysis_passes::haec055f3322a38aa
  22:     0x7f86297c4150 - rustc_driver::driver::compile_input::hd9f060ee16a643fb
  23:     0x7f862980e844 - rustc_driver::run_compiler::h762802568c0e140e
  24:     0x7f862971aedb - std::panicking::try::do_call::h935e2f773deaf841
  25:     0x7f862944ec8a - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  26:     0x7f8629743112 - <F as alloc::boxed::FnBox<A>>::call_box::he43811d1f6894655
  27:     0x7f8629444804 - std::sys::imp::thread::Thread::new::thread_start::he668872ac11287ba
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/liballoc/boxed.rs:624
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
  28:     0x7f8621efe6b9 - start_thread
  29:     0x7f86290fa82c - clone
  30:                0x0 - <unknown>

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: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc_errors/lib.rs:375
stack backtrace:
   1:     0x7ff9adb2440c - std::sys::imp::backtrace::tracing::imp::write::hf33ae72d0baa11ed
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:42
   2:     0x7ff9adb329ae - std::panicking::default_hook::{{closure}}::h59672b733cc6a455
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:351
   3:     0x7ff9adb32553 - std::panicking::default_hook::h1670459d2f3f8843
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:361
   4:     0x7ff9adb32e4b - std::panicking::rust_panic_with_hook::hcf0ddb069e7beee7
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/panicking.rs:555
   5:     0x7ff9aaaa49f8 - std::panicking::begin_panic::h7615035f91af0a46
   6:     0x7ff9aac55165 - rustc::session::opt_span_bug_fmt::{{closure}}::hb8dfe55fdd29ba42
   7:     0x7ff9aac54c65 - rustc::session::opt_span_bug_fmt::h0cd2e09801797662
   8:     0x7ff9aac54af4 - rustc::session::span_bug_fmt::hd9d57beec0176564
   9:     0x7ff9aac0fe05 - rustc::middle::mem_categorization::MemCategorizationContext::cat_pattern_::hf9ee6cc28f4950bf
  10:     0x7ff9aabeffe8 - rustc::middle::expr_use_visitor::ExprUseVisitor::walk_expr::h67cf415f4e516db4
  11:     0x7ff9aabeee41 - rustc::middle::expr_use_visitor::ExprUseVisitor::consume_body::hf960393f75684590
  12:     0x7ff9ac4f6a1c - <rustc_typeck::check::upvar::AdjustBorrowKind<'a, 'gcx, 'tcx> as rustc::hir::intravisit::Visitor<'gcx>>::visit_fn::hcfd8923185beae25
  13:     0x7ff9ac496267 - rustc::hir::intravisit::walk_expr::hb6d0c21c465f62f9
  14:     0x7ff9ac495c1e - rustc::hir::intravisit::walk_expr::hb6d0c21c465f62f9
  15:     0x7ff9ac495f4e - rustc::hir::intravisit::walk_expr::hb6d0c21c465f62f9
  16:     0x7ff9ac4f5210 - rustc_typeck::check::upvar::<impl rustc_typeck::check::FnCtxt<'a, 'gcx, 'tcx>>::closure_analyze::h260e6c5912cc14b4
  17:     0x7ff9ac5256a6 - rustc_typeck::check::check_bare_fn::h9f0916104d636ee0
  18:     0x7ff9ac522875 - rustc_typeck::check::check_item_bodies::hd9e8c6a8692f314b
  19:     0x7ff9ac590497 - rustc_typeck::check_crate::h8c159f70d1009b33
  20:     0x7ff9aded0cd7 - rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}::h040eea107b0d299b
  21:     0x7ff9adecd6c6 - rustc_driver::driver::phase_3_run_analysis_passes::haec055f3322a38aa
  22:     0x7ff9adeb1150 - rustc_driver::driver::compile_input::hd9f060ee16a643fb
  23:     0x7ff9adefb844 - rustc_driver::run_compiler::h762802568c0e140e
  24:     0x7ff9ade07edb - std::panicking::try::do_call::h935e2f773deaf841
  25:     0x7ff9adb3bc8a - __rust_maybe_catch_panic
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libpanic_unwind/lib.rs:98
  26:     0x7ff9ade30112 - <F as alloc::boxed::FnBox<A>>::call_box::he43811d1f6894655
  27:     0x7ff9adb31804 - std::sys::imp::thread::Thread::new::thread_start::he668872ac11287ba
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/liballoc/boxed.rs:624
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys_common/thread.rs:21
                        at /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libstd/sys/unix/thread.rs:84
  28:     0x7ff9a65eb6b9 - start_thread
  29:     0x7ff9ad7e782c - clone
  30:                0x0 - <unknown>

error: Could not compile `brain`.
Build failed, waiting for other jobs to finish...
error: build failed

Since I was in the middle of editing, there's no commit to point to, so I just attached my source code as is so you have something to debug. When you download it and run cargo test, the compiler should panic. The repo is called brain-lang/brain.

I don't know how to narrow this issue down, or else I would try to find a smaller example for you. Hope this is good enough.

brain-rustc-panic.zip

@sunjay
Copy link
Member Author

sunjay commented Apr 10, 2017

Some context for the change that caused this:

error: internal compiler error: /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/librustc/middle/mem_categorization.rs:1175: tuple struct pattern didn't resolve to variant or struct Err
  --> src/operations/type_definition.rs:15:13
   |
15 |             ScopeItem::Type(id) => Ok(id),
   |             ^^^^^^^^^^^^^^^^^^^

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

Before this error happened, I changed the file src/operations/scope.rs. I split ScopeItem into two structs, ScopeItem and ScopeType. I was relying on the compiler to find all the places where that change would effect things, and it seems that something went wrong in the compiler while trying to do that.

@sunjay
Copy link
Member Author

sunjay commented Apr 10, 2017

Once I fix that, everything works again. No more compiler panic. So it seems to have something to do with when I split up that struct. All the messed up pattern matches caused a panic. (Actually just fixing 2 broken pattern matches fixed the problem.)

@calc0000
Copy link

calc0000 commented Jun 8, 2017

I've just encountered this myself. I managed to reduce it down:

struct Foo;

fn main() {
    || if let Foo::NotEvenReal() = Foo {};
}

It looks like this happens when a closure's body is a single (non-block) expression, and a tuple struct pattern is used somewhere in the expression. A simple workaround (if anyone needs one for some reason), then, is to just make the closure body a block:

struct Foo;

fn main() {
    || { if let Foo::NotEvenReal() = Foo {} };
}

@Mark-Simulacrum Mark-Simulacrum added 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 Jun 23, 2017
@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 22, 2017
topecongiro added a commit to topecongiro/rust that referenced this issue Dec 30, 2017
bors added a commit that referenced this issue Dec 31, 2017
Add tests on fixed ICEs

Closes #29924. Closes #38857. Closes #39665. Closes #39872.
Closes #41210. Closes #41880. Closes #43483.

Note that compile-fail/E0599.rs is for #41210.
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. 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.
Projects
None yet
Development

No branches or pull requests

3 participants