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

rustc panicked at 'LocalTableInContext: key not found', libcore/option.rs:960:5 #51798

Closed
jeremyBanks opened this issue Jun 26, 2018 · 11 comments · Fixed by #69192
Closed

rustc panicked at 'LocalTableInContext: key not found', libcore/option.rs:960:5 #51798

jeremyBanks opened this issue Jun 26, 2018 · 11 comments · Fixed by #69192
Labels
C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been 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.

Comments

@jeremyBanks
Copy link
Contributor

jeremyBanks commented Jun 26, 2018

I'm sorry, I haven't reduced this at all, and I'm sure the code is awful, but the error message said you'd appreciate a bug report.

I tried this code:

jeremyBanks/0dmg@ae3b7d2
using cargo clean && RUST_BACKTRACE=1 cargo run --verbose

I expected to see this happen: my program would run, or the compiler would give one of its typical helpful error messages!

Instead, this happened:

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.28.0-nightly (01cc982e9 2018-06-24) running on x86_64-unknown-linux-gnu

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

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

Meta

I am using the Windows Linux Subsystem thing with Debian or Ubuntu, I think.

rustc --version --verbose:

rustc 1.28.0-nightly (01cc982e9 2018-06-24)
binary: rustc
commit-hash: 01cc982e936120acb0424e41de14e42ba2d88c6f
commit-date: 2018-06-24
host: x86_64-unknown-linux-gnu
release: 1.28.0-nightly
LLVM version: 6.0

cargo --version --verbose:

cargo 1.28.0-nightly (e2348c2db 2018-06-07)
release: 1.28.0
commit-hash: e2348c2db296ce33428933c3ab8786d5f3c54a2e
commit-date: 2018-06-07

Backtrace:

error: internal compiler error: no type-dependent def for method call                                                                                                                        
  --> src/server.rs:48:17                                                                                                                                                                    
   |                                                                                                                                                                                         
48 |                 display.write_to(&mut encoded_image, image::ImageOutputFormat::PNG);                                                                                                    
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                     
                                                                                                                                                                                             
thread 'rustc' panicked at 'LocalTableInContext: key not found', libcore/option.rs:960:5                                                                                                     
stack backtrace:                                                                                                                                                                             
   0:     0x7f6d10abf07e - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h1b3a1496bdd47d5b                                                                                      
                               at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49                                                                                                              
   1:     0x7f6d10a96046 - std::sys_common::backtrace::print::h2f040662be69463e                                                                                                              
                               at libstd/sys_common/backtrace.rs:71                                                                                                                          
                               at libstd/sys_common/backtrace.rs:59                                                                                                                          
   2:     0x7f6d10ac60ed - std::panicking::default_hook::{{closure}}::h796d09e60146b74e                                                                                                      
                               at libstd/panicking.rs:211                                                                                                                                    
   3:     0x7f6d10ac5e60 - std::panicking::default_hook::h591ad3dc45e922d2                                                                                                                   
                               at libstd/panicking.rs:227                                                                                                                                    
   4:     0x7f6d0d0ed855 - rustc::util::common::panic_hook::h93012055300dea77                                                                                                                
   5:     0x7f6d10ac6873 - std::panicking::rust_panic_with_hook::h704ba6b5b270af4d                                                                                                           
                               at libstd/panicking.rs:515                                                                                                                                    
   6:     0x7f6d10ac65c9 - std::panicking::continue_panic_fmt::hf3634b62bc28487a                                                                                                             
                               at libstd/panicking.rs:426                                                                                                                                    
   7:     0x7f6d10ac6315 - rust_begin_unwind                                                                                                                                                 
                               at libstd/panicking.rs:337                                                                                                                                    
   8:     0x7f6d10b4025b - core::panicking::panic_fmt::hf24f6f6052fa35b2                                                                                                                     
                               at libcore/panicking.rs:92                                                                                                                                    
   9:     0x7f6d10b18bd1 - core::option::expect_failed::hcb17cddc36ef26d5                                                                                                                    
                               at libcore/option.rs:960                                                                                                                                      
  10:     0x7f6d0f62519a - <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::h9e6d5b384161a649                                             
  11:     0x7f6d0f60820b - rustc::hir::intravisit::walk_local::h9923da8b04f99efa                                                                                                             
  12:     0x7f6d0f607dae - rustc::hir::intravisit::walk_block::h33929fd27434ca57                                                                                                             
  13:     0x7f6d0f62512c - <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::h9e6d5b384161a649                                             
  14:     0x7f6d0f60820b - rustc::hir::intravisit::walk_local::h9923da8b04f99efa                                                                                                             
  15:     0x7f6d0f607dae - rustc::hir::intravisit::walk_block::h33929fd27434ca57                                                                                                             
  16:     0x7f6d0f62512c - <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::h9e6d5b384161a649                                             
  17:     0x7f6d0f61671e - rustc::hir::intravisit::walk_expr::he552c42b919e1b81                                                                                                              
  18:     0x7f6d0f62512c - <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::h9e6d5b384161a649                                             
  19:     0x7f6d0f62512c - <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr::h9e6d5b384161a649                                             
  20:     0x7f6d0f624d1c - <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_nested_body::hdc8c701d5e5bd510                                      
  21:     0x7f6d0f625cd8 - <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_impl_item::h072602c658b2a316                                        
  22:     0x7f6d0f617662 - rustc::hir::intravisit::walk_item::h470024412920b632                                                                                                              
  23:     0x7f6d0f6259ed - <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::ha50b33ab6440822d                                             
  24:     0x7f6d0f617976 - rustc::hir::intravisit::walk_item::h470024412920b632                                                                                                              
  25:     0x7f6d0f6259ed - <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item::ha50b33ab6440822d                                             
  26:     0x7f6d0f628eb7 - rustc_privacy::privacy_access_levels::hd31f9a283676d277                                                                                                           
  27:     0x7f6d0ce0aa38 - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::privacy_access_levels<'tcx>>::compute::hd400623c3414d3e2    
  28:     0x7f6d0cd51f03 - rustc::ty::context::tls::with_context::h03c6fdd2edf55524                                                                                                          
  29:     0x7f6d0cc70498 - rustc::dep_graph::graph::DepGraph::with_task_impl::ha5a5ab6b46058ac3                                                                                              
  30:     0x7f6d0cddee22 - rustc::ty::context::tls::with_related_context::ha15b602b83ee2289                                                                                                  
  31:     0x7f6d0cf02a32 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job::hbe6ac0c34ea931e3                                            
  32:     0x7f6d0cfc01b4 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query::h9b8bc4da9a1e7848                                                       
  33:     0x7f6d10e6c082 - rustc::util::common::time::h0fa6f741c87b6466                                                                                                                      
  34:     0x7f6d10f02332 - rustc::ty::context::tls::enter_context::h84146176419ecbc3                                                                                                         
  35:     0x7f6d10eb248a - <std::thread::local::LocalKey<T>>::with::heeb19f7ad79c895c                                                                                                        
  36:     0x7f6d10e19c52 - rustc::ty::context::TyCtxt::create_and_enter::h55f2408bc01b7235                                                                                                   
  37:     0x7f6d10e5d010 - rustc_driver::driver::compile_input::hcefbb4026998c8a0                                                                                                            
  38:     0x7f6d10ee7eab - rustc_driver::run_compiler_with_pool::hf3c65b5bd222c3ca                                                                                                           
  39:     0x7f6d10e4c95b - <scoped_tls::ScopedKey<T>>::set::h8edaec88de07c236                                                                                                                
  40:     0x7f6d10e221cd - syntax::with_globals::hb0aff83358220802                                                                                                                           
  41:     0x7f6d10eba4b2 - std::sys_common::backtrace::__rust_begin_short_backtrace::hbd943a03a0952add                                                                                       
  42:     0x7f6d10ad49e9 - __rust_maybe_catch_panic                                                                                                                                          
                               at libpanic_unwind/lib.rs:105                                                                                                                                 
  43:     0x7f6d10e59fbd - <F as alloc::boxed::FnBox<A>>::call_box::hbe51a9318c82f125                                                                                                        
  44:     0x7f6d10ac561a - std::sys_common::thread::start_thread::h9f808e1cb13674ec                                                                                                          
                               at /checkout/src/liballoc/boxed.rs:650                                                                                                                        
                               at libstd/sys_common/thread.rs:24                                                                                                                             
  45:     0x7f6d10a95015 - std::sys::unix::thread::Thread::new::thread_start::h668a95d388fe6493                                                                                              
                               at libstd/sys/unix/thread.rs:90                                                                                                                               
  46:     0x7f6d0acf76b9 - start_thread                                                                                                                                                      
  47:     0x7f6d1076741c - clone                                                                                                                                                             
  48:                0x0 - <unknown>                                                                                                                                                         
query stack during panic:                                                                                                                                                                    
#0 [privacy_access_levels] privacy access levels                                                                                                                                             
end of query stack                                                                                                                                                                           
error: aborting due to previous error                                                                                                                                                        
@jeremyBanks
Copy link
Contributor Author

If I use cargo doc I get a different stack trace:

RUST_BACKTRACE=full cargo doc --no-deps --verbose

error: internal compiler error: librustc/hir/def.rs:249: attempted .def_id() on invalid def: Err

thread 'rustc' panicked at 'Box<Any>', librustc_errors/lib.rs:554:9
stack backtrace:
   0:     0x7fc54d88f07e - std::sys::unix::backtrace::tracing::imp::unwind_backtrace::h1b3a1496bdd47d5b
                               at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1:     0x7fc54d866046 - std::sys_common::backtrace::print::h2f040662be69463e
                               at libstd/sys_common/backtrace.rs:71
                               at libstd/sys_common/backtrace.rs:59
   2:     0x7fc54d8960ed - std::panicking::default_hook::{{closure}}::h796d09e60146b74e
                               at libstd/panicking.rs:211
   3:     0x7fc54d895e60 - std::panicking::default_hook::h591ad3dc45e922d2
                               at libstd/panicking.rs:227
   4:     0x7fc54d89681c - std::panicking::rust_panic_with_hook::h704ba6b5b270af4d
                               at libstd/panicking.rs:511
   5:     0x7fc54e70621e - std::panicking::begin_panic::h2992736397ee35b4
   6:     0x7fc54e701961 - rustc_errors::Handler::bug::h554f2c448ef9c119
   7:     0x7fc54f58b1ac - rustc::session::opt_span_bug_fmt::{{closure}}::h2c6e2219b9bc9cfc
   8:     0x7fc54f644ee9 - rustc::ty::context::tls::with_opt::{{closure}}::hef18231c8fd1d270
   9:     0x7fc54f58c16f - rustc::ty::context::tls::with_context_opt::h8d5ef6a7c76a84a2
  10:     0x7fc54f644746 - rustc::ty::context::tls::with_opt::haf89db8d0634e2b3
  11:     0x7fc54f4f05c4 - rustc::session::opt_span_bug_fmt::heeba45021378ece2
  12:     0x7fc54f4f0536 - rustc::session::bug_fmt::h83c885c8d9e7b309
  13:     0x7fc54f673266 - rustc::hir::def::Def::def_id::h8d0261bb38bcfabf
  14:     0x7fc5523a64cc - rustc_privacy::ObsoleteVisiblePrivateTypesVisitor::path_is_private_type::h7c353bb46816e7d3
  15:     0x7fc5523929c3 - rustc::hir::intravisit::walk_ty::h73e89da7517b1fad
  16:     0x7fc5523929ea - rustc::hir::intravisit::walk_ty::h73e89da7517b1fad
  17:     0x7fc552398889 - rustc::hir::intravisit::walk_item::h91f8d2a1af24c66e
  18:     0x7fc552398a36 - rustc::hir::intravisit::walk_item::h91f8d2a1af24c66e
  19:     0x7fc5523a90d4 - rustc_privacy::privacy_access_levels::hd31f9a283676d277
  20:     0x7fc54f645a38 - rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::privacy_access_levels<'tcx>>::compute::hd400623c3414d3e2
  21:     0x7fc54f4abb46 - rustc::dep_graph::graph::DepGraph::with_task_impl::ha5a5ab6b46058ac3
  22:     0x7fc54f619e66 - rustc::ty::context::tls::with_related_context::ha15b602b83ee2289
  23:     0x7fc54f73da32 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job::hbe6ac0c34ea931e3
  24:     0x7fc54f7faf86 - rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query::h9b8bc4da9a1e7848
  25:     0x7fc55360cf02 - rustc::util::common::time::h5cb1caf806803c79
                               at /checkout/src/librustc_driver/driver.rs:1257
                               at /checkout/src/librustc/util/common.rs:166
                               at /checkout/src/librustc/util/common.rs:160
  26:     0x7fc55348bbc6 - rustc::ty::context::tls::enter_context::h49bbe398e026ec5b
                               at /checkout/src/librustc_driver/driver.rs:1257
                               at /checkout/src/librustc/ty/context.rs:1861
                               at /checkout/src/librustc/ty/context.rs:1829
                               at /checkout/src/librustc/ty/context.rs:1768
                               at /checkout/src/librustc/ty/context.rs:1828
  27:     0x7fc553460e75 - <std::thread::local::LocalKey<T>>::with::h2023723a488f5b39
                               at /checkout/src/librustc/ty/context.rs:1860
                               at /checkout/src/librustc/ty/context.rs:1818
                               at /checkout/src/libstd/thread/local.rs:294
                               at /checkout/src/libstd/thread/local.rs:248
                               at /checkout/src/librustc/ty/context.rs:1810
                               at /checkout/src/libstd/thread/local.rs:294
                               at /checkout/src/libstd/thread/local.rs:248
  28:     0x7fc553657adb - rustc::ty::context::TyCtxt::create_and_enter::h1dc717f5ab9cfb3d
                               at /checkout/src/librustc/ty/context.rs:1802
                               at /checkout/src/librustc/ty/context.rs:1840
                               at /checkout/src/librustc/ty/context.rs:1185
  29:     0x7fc5534e277e - rustc_driver::driver::phase_3_run_analysis_passes::h96fb344e54968fd5
                               at /checkout/src/librustc_driver/driver.rs:1218
  30:     0x7fc5535c1453 - <scoped_tls::ScopedKey<T>>::set::h173cdac992fc7603
                               at librustdoc/core.rs:303
                               at /checkout/src/librustc_driver/driver.rs:73
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.1/src/lib.rs:155
  31:     0x7fc5535f5be2 - rustdoc::core::run_core::h8cb60a0859be166b
                               at /checkout/src/librustc_driver/driver.rs:72
                               at librustdoc/core.rs:231
  32:     0x7fc5535c26cf - <scoped_tls::ScopedKey<T>>::set::h958242fdc5235104
                               at librustdoc/lib.rs:645
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.1/src/lib.rs:155
                               at /checkout/src/libsyntax/lib.rs:98
                               at /cargo/registry/src/github.com-1ecc6299db9ec823/scoped-tls-0.1.1/src/lib.rs:155
  33:     0x7fc553610d0d - syntax::with_globals::ha81c059769a61bdd
                               at /checkout/src/libsyntax/lib.rs:97
  34:     0x7fc553460117 - std::sys_common::backtrace::__rust_begin_short_backtrace::haaad03c578aabb3a
                               at librustdoc/lib.rs:641
                               at /checkout/src/librustc_driver/lib.rs:1613
                               at /checkout/src/libstd/sys_common/backtrace.rs:136
  35:     0x7fc553481da5 - std::panicking::try::do_call::h42c4cb447982246d
                               at /checkout/src/libstd/thread/mod.rs:409
                               at /checkout/src/libstd/panic.rs:313
                               at /checkout/src/libstd/panicking.rs:310
  36:     0x7fc54d8a49e9 - __rust_maybe_catch_panic
                               at libpanic_unwind/lib.rs:105
  37:     0x7fc553453a80 - <F as alloc::boxed::FnBox<A>>::call_box::h00353a92fe7e9aaf
                               at /checkout/src/libstd/panicking.rs:289
                               at /checkout/src/libstd/panic.rs:397
                               at /checkout/src/libstd/thread/mod.rs:408
                               at /checkout/src/liballoc/boxed.rs:640
  38:     0x7fc54d89561a - std::sys_common::thread::start_thread::h9f808e1cb13674ec
                               at /checkout/src/liballoc/boxed.rs:650
                               at libstd/sys_common/thread.rs:24
  39:     0x7fc54d865015 - std::sys::unix::thread::Thread::new::thread_start::h668a95d388fe6493
                               at libstd/sys/unix/thread.rs:90
  40:     0x7fc54d5e76b9 - start_thread
  41:     0x7fc54d0f741c - clone
  42:                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: rustc 1.28.0-nightly (01cc982e9 2018-06-24) running on x86_64-unknown-linux-gnu

note: compiler flags: -Z unstable-options

error: Could not document `zerodmg`.

Caused by:
  process didn't exit successfully: `rustdoc -Zunstable-options --edition=2018 --crate-name zerodmg src/main.rs -o /mnt/c/Users/_/0dmg/target/doc -L dependency=/mnt/c/Users/_/0dmg/target/debug/deps --extern futures=/mnt/c/Users/_/0dmg/target/debug/deps/libfutures-839041d02c22f16f.rmeta --extern hyper=/mnt/c/Users/_/0dmg/target/debug/deps/libhyper-59f22dbfdbf31d90.rmeta --extern image=/mnt/c/Users/_/0dmg/target/debug/deps/libimage-b5966e2d05b7365d.rmeta --extern rand=/mnt/c/Users/_/0dmg/target/debug/deps/librand-8290a2bbec565ae8.rmeta --extern tokio=/mnt/c/Users/_/0dmg/target/debug/deps/libtokio-1f3f1dff24a2c94b.rmeta --extern zerodmg_emulator=/mnt/c/Users/_/0dmg/target/debug/deps/libzerodmg_emulator-c82403191bdbc04c.rmeta --extern zerodmg_utils=/mnt/c/Users/_/0dmg/target/debug/deps/libzerodmg_utils-ae73f0f234e525dd.rmeta` (exit code: 101)

@kennytm kennytm 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. C-bug Category: This is a bug. labels Jun 26, 2018
@jeremyBanks
Copy link
Contributor Author

The crash stopped occurring in my code when I fixed an invalid import: use crate::emulator;

see jeremyBanks/0dmg@976629e

@varkor
Copy link
Member

varkor commented Jun 28, 2018

I'm pretty certain this is caused by type_dependent_defs() being directly indexed without being checked here:

let def_id = self.tables.type_dependent_defs()[expr.hir_id].def_id();

But, really, it'd be nice to have a reduced test case so we can confirm the bug is fixed afterwards.

@varkor varkor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Jun 28, 2018
@jeremyBanks
Copy link
Contributor Author

Makes sense. I'll try to pare it down to something useful.

jeremyBanks added a commit to jeremyBanks/0dmg that referenced this issue Jun 28, 2018
@jeremyBanks
Copy link
Contributor Author

jeremyBanks commented Jun 28, 2018

I'm failing to reproduce this crash without using multiple crates, so I can't figure out how to put it in a Playground example or should_fail doc test, but here's a reduced example (jeremyBanks/0dmg@9758f25).

Source

./Cargo.toml

cargo-features = ["edition"]

[package]
publish = false
edition = "2018"
name = "rust-issue-51798-example-parent"
version = "1.0.0"

[dependencies]
rust-issue-51798-example-child = { version = "1.0.0", path = "child" }

./src/lib.rs

#![feature(rust_2018_preview)]

use rust_issue_51798_example_child;

mod server {
    use crate::rust_issue_51798_example_child;

    fn f() {
        let mut v = rust_issue_51798_example_child::vec();
        v.clear();
    }
}

./child/Cargo.toml

cargo-features = ["edition"]

[package]
publish = false
edition = "2018"
name = "rust-issue-51798-example-child"
version = "1.0.0"

./child/src/lib.rs

pub fn vec() -> Vec<u8> { vec![] }

Output of cargo clean && cargo build

   Compiling rust-issue-51798-example-child v1.0.0 (file:///mnt/c/Users/_/0dmg/child)
   Compiling rust-issue-51798-example-parent v1.0.0 (file:///mnt/c/Users/_/0dmg)
error: internal compiler error: no type-dependent def for method call
  --> src/lib.rs:10:9
   |
10 |         v.clear();
   |         ^^^^^^^^^

thread 'rustc' panicked at 'LocalTableInContext: key not found', libcore/option.rs:960:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:515
   6: std::panicking::continue_panic_fmt
             at libstd/panicking.rs:426
   7: rust_begin_unwind
             at libstd/panicking.rs:337
   8: core::panicking::panic_fmt
             at libcore/panicking.rs:92
   9: core::option::expect_failed
             at libcore/option.rs:960
  10: <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
  11: rustc::hir::intravisit::walk_block
  12: <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_expr
  13: <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_nested_body
  14: <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  15: rustc::hir::intravisit::walk_item
  16: <rustc_privacy::TypePrivacyVisitor<'a, 'tcx> as rustc::hir::intravisit::Visitor<'tcx>>::visit_item
  17: rustc_privacy::privacy_access_levels
  18: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::privacy_access_levels<'tcx>>::compute
  19: rustc::ty::context::tls::with_context
  20: rustc::dep_graph::graph::DepGraph::with_task_impl
  21: rustc::ty::context::tls::with_related_context
  22: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::force_query_with_job
  23: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::get_query
  24: rustc::util::common::time
  25: rustc::ty::context::tls::enter_context
  26: <std::thread::local::LocalKey<T>>::with
  27: rustc::ty::context::TyCtxt::create_and_enter
  28: rustc_driver::driver::compile_input
  29: rustc_driver::run_compiler_with_pool
  30: <scoped_tls::ScopedKey<T>>::set
  31: syntax::with_globals
query stack during panic:
#0 [privacy_access_levels] privacy access levels
end of query stack
error: aborting due to previous error


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.28.0-nightly (cd494c1f0 2018-06-27) running on x86_64-unknown-linux-gnu

note: compiler flags: -C debuginfo=2 -C incremental --crate-type lib

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

error: Could not compile `rust-issue-51798-example-parent`.

To learn more, run the command again with --verbose.

@jeremyBanks
Copy link
Contributor Author

Okay, I've got the failure occurring in a compiler test at jeremyBanks/rust@b9fa771.

src/test/compile-fail/auxiliary/issue-51798.rs

#![crate_name="rust_issue_51798_example_child"]
#![crate_type = "lib"]

pub fn vec() -> Vec<u8> { vec![] }

src/test/compile-fail/issue-51798.rs

// compile-flags:--edition=2018
// aux-build:issue-51798.rs
#![crate_type = "lib"]

use rust_issue_51798_example_child;

mod server {
    use crate::rust_issue_51798_example_child;

    fn f() {
        let mut v = rust_issue_51798_example_child::vec();
        v.clear();
    }
}

Result:

thread '[compile-fail] compile-fail/issue-51798.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3140:9


failures:
    [compile-fail] compile-fail/issue-51798.rs

test result: FAILED. 1 passed; 1 failed; 2428 ignored; 0 measured; 0 filtered out

thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:498:22

If I understand correctly, it will be possible to turn this into a regression test by annotating it with the desired non-panic output, once this issue has been fixed and we know what the fixed output looks like. But since we're not sure what the will look like, there'd be no point trying to get this merged yet.

bors added a commit that referenced this issue Jul 1, 2018
Always check type_dependent_defs

Directly indexing into `type_dependent_defs` has caused multiple ICEs in the past (#46771, #49241, etc.) and is almost certainly responsible for #51798 too. This PR ensures we always check `type_dependent_defs` first, which should prevent any more of these (or at least make them easier to track down).
@varkor
Copy link
Member

varkor commented Jul 2, 2018

@jeremyBanks: now that #51882 is merged and should be in the next Nightly, could you check your test-case again to see whether it's fixed? I didn't have time to add your test case before it was merged. Thanks!

@jeremyBanks
Copy link
Contributor Author

jeremyBanks commented Jul 2, 2018

@varkor I think it's fixed.

My stand-alone test case produces the same initial error message of "no type-dependent def for method call", but it no longer displays any panic; it seems to exit cleanly.

Using rustc built from master:

+ /home/jeremy/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustc --edition=2018 --crate-type lib --out-dir ./target -L dependency=./target child.rs --crate-name rust_issue_51798_example_child -C metadata=arbitrary_child_id -C extra-filename=-arbitrary_child_id
+ /home/jeremy/rust/build/x86_64-unknown-linux-gnu/stage2/bin/rustc --edition=2018 --crate-type lib --out-dir ./target -L dependency=./target parent.rs --crate-name rust_issue_51798_example_parent -C metadata=arbitrary_parent_id -C extra-filename=-arbitrary_parent_id --extern rust_issue_51798_example_child=./target/librust_issue_51798_example_child-arbitrary_child_id.rlib
error: internal compiler error: no type-dependent def for method call
 --> parent.rs:8:9
  |
8 |         v.clear();
  |         ^^^^^^^^^

error: aborting due to previous error

Using rustc 1.28.0-nightly:

+ rustc +nightly --edition=2018 --crate-type lib --out-dir ./target -L dependency=./target child.rs --crate-name rust_issue_51798_example_child -C metadata=arbitrary_child_id -C extra-filename=-arbitrary_child_id
+ rustc +nightly --edition=2018 --crate-type lib --out-dir ./target -L dependency=./target parent.rs --crate-name rust_issue_51798_example_parent -C metadata=arbitrary_parent_id -C extra-filename=-arbitrary_parent_id --extern rust_issue_51798_example_child=./target/librust_issue_51798_example_child-arbitrary_child_id.rlib
error: internal compiler error: no type-dependent def for method call
 --> parent.rs:8:9
  |
8 |         v.clear();
  |         ^^^^^^^^^

thread 'main' panicked at 'LocalTableInContext: key not found', libcore/option.rs:960:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to previous error


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.28.0-nightly (e3bf634e0 2018-06-28) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib

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

(Now running in a normal Debian VM. Sorry for the constantly-changing platform. :P)

@jeremyBanks
Copy link
Contributor Author

Sorry! I didn't mean to submit the post yet, or close the issue, but I mis-clicked.

I'm still trying to figure out the appropriate annotations to make this pass as a compile-fail test. @varkor If I get the test working behaving properly, would it be useful to send a PR to add my regression test, or is this too small of an issue to warrant one?

@varkor
Copy link
Member

varkor commented Jul 2, 2018

@jeremyBanks: yes, a regression test would be useful here. Actually, I don't think the behaviour is even correct here — it shouldn't be displaying that error at all, even if it's not actually crashing.

jeremyBanks added a commit to jeremyBanks/rust that referenced this issue Jul 3, 2018
@steveklabnik
Copy link
Member

Did a test ever get added here?

Centril added a commit to Centril/rust that referenced this issue Feb 17, 2020
@bors bors closed this as completed in d1f175b Feb 18, 2020
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. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants