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

-Z save-analysis ICE when processing impl under an fn item #65411

Closed
arturoc opened this issue Oct 14, 2019 · 4 comments · Fixed by #65511
Closed

-Z save-analysis ICE when processing impl under an fn item #65411

arturoc opened this issue Oct 14, 2019 · 4 comments · Fixed by #65511
Assignees
Labels
A-save-analysis Area: saving results of analyses such as inference and borrowck results to a file. C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@arturoc
Copy link
Contributor

arturoc commented Oct 14, 2019

While compiling rayon:

{"message":"src/librustc/ty/context.rs:211: node type <B>::Item (hir_id=HirId { owner: DefIndex(366), local_id: 15 }) with HirId::owner DefId(0:366 ~ rayon[97c5]::iter[0]::chain[0]::{{impl}}[1]::with_producer[0]::{{impl}}[0]) cannot be placed in TypeckTables with local_id_root DefId(0:358 ~ rayon[97c5]::iter[0]::chain[0]::{{impl}}[1]::with_producer[0])","code":null,"level":"error: internal compiler error","spans":[],"children":[],"rendered":"error: internal compiler error: src/librustc/ty/context.rs:211: node type <B>::Item (hir_id=HirId { owner: DefIndex(366), local_id: 15 }) with HirId::owner DefId(0:366 ~ rayon[97c5]::iter[0]::chain[0]::{{impl}}[1]::with_producer[0]::{{impl}}[0]) cannot be placed in TypeckTables with local_id_root DefId(0:358 ~ rayon[97c5]::iter[0]::chain[0]::{{impl}}[1]::with_producer[0])\n\n"}
thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:917:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.51.al-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.51.al-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1028
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:189
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:206
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:473
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_context_opt
  18: rustc::ty::context::tls::with_opt
  19: rustc::util::bug::opt_span_bug_fmt
  20: rustc::util::bug::bug_fmt
  21: rustc::ty::context::validate_hir_id_for_typeck_tables::{{closure}}
  22: rustc::ty::context::tls::with::{{closure}}
  23: rustc::ty::context::tls::with_context::{{closure}}
  24: rustc::ty::context::tls::with_context_opt
  25: rustc::ty::context::tls::with_context
  26: rustc::ty::context::tls::with
  27: rustc::ty::context::TypeckTables::qpath_res
  28: rustc_save_analysis::SaveContext::get_path_res
  29: <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_ty
  30: rustc_save_analysis::dump_visitor::DumpVisitor::process_path
  31: <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_item
  32: rustc_save_analysis::dump_visitor::DumpVisitor::process_method::{{closure}}
  33: rustc_save_analysis::dump_visitor::DumpVisitor::process_method
  34: <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_item
  35: <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_item
  36: <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_item
  37: <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_mod
  38: rustc::dep_graph::graph::DepGraph::with_ignore
  39: rustc_driver::run_compiler::{{closure}}::{{closure}}::{{closure}}
  40: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  41: rustc_interface::passes::create_global_ctxt::{{closure}}
  42: rustc_interface::interface::run_compiler_in_existing_thread_pool
  43: std::thread::local::LocalKey<T>::with
  44: scoped_tls::ScopedKey<T>::set
  45: syntax::with_globals
@jonas-schievink jonas-schievink added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 14, 2019
@Centril Centril added the A-save-analysis Area: saving results of analyses such as inference and borrowck results to a file. label Oct 14, 2019
@Centril
Copy link
Contributor

Centril commented Oct 14, 2019

cc @Xanewok

@pnkfelix pnkfelix added the E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example label Oct 17, 2019
@pnkfelix
Copy link
Member

triage: P-high, assigning to @Xanewok . Removing nomination label.

@pnkfelix pnkfelix added P-high High priority and removed I-nominated labels Oct 17, 2019
@pnkfelix pnkfelix changed the title rustc panic in 1.40.0-nightly (c27f7568b 2019-10-13) -Z save-analysis ICE when processing impl under an fn item Oct 18, 2019
@pnkfelix
Copy link
Member

The fact that this bug was unknown until now strikes me as a sign that we have never attempted to run -Z save-analysis on the rustc test suite (i.e. compiletest).

is this true? Would it be worthwhile to attempt that experiment?

Centril added a commit to Centril/rust that referenced this issue Oct 18, 2019
save-analysis: Nest tables when processing impl block definitions

Similar to rust-lang#65353 (which this PR should've been a part of), however in this case we didn't previously nest the tables when processing trait paths in impl block declarations.

Closes rust-lang#65411
tmandry added a commit to tmandry/rust that referenced this issue Oct 18, 2019
save-analysis: Nest tables when processing impl block definitions

Similar to rust-lang#65353 (which this PR should've been a part of), however in this case we didn't previously nest the tables when processing trait paths in impl block declarations.

Closes rust-lang#65411
@bors bors closed this as completed in 156a55e Oct 19, 2019
@Xanewok
Copy link
Member

Xanewok commented Oct 20, 2019

I'm not sure if this is the correct approach, but I just executed the ./x.py test with the following patch applied:

diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index ea31f37c7a5..66546c5ca0c 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -2869,6 +2869,7 @@ impl<'test> TestCx<'test> {
         // We don't want RUSTFLAGS set from the outside to interfere with
         // compiler flags set in the test cases:
         cmd.env_remove("RUSTFLAGS");
+        cmd.env("RUSTFLAGS", "-Zsave-analysis");
 
         // Use dynamic musl for tests because static doesn't allow creating dylibs
         if self.config.host.contains("musl") {

and the test suite did crash/ended up all green.

It might be a good idea to always run the tests along with save-analysis passed. Should that be optionally enabled? Should we run it, e.g. in the -tools container?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-save-analysis Area: saving results of analyses such as inference and borrowck results to a file. C-bug Category: This is a bug. E-needs-mcve Call for participation: This issue has a repro, but needs a Minimal Complete and Verifiable Example I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority 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.

5 participants