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

Compiler panic compiling libcore #43982

Closed
dvc94ch opened this issue Aug 18, 2017 · 15 comments · Fixed by #64250
Closed

Compiler panic compiling libcore #43982

dvc94ch opened this issue Aug 18, 2017 · 15 comments · Fixed by #64250
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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dvc94ch
Copy link
Contributor

dvc94ch commented Aug 18, 2017

Last rebase was 11. Aug. Using rust-llvm-2017-07-20.

EDIT: First bad commit is 783ccc4

Compiling with:

	cd $(rust_src) && \
	./configure --enable-debug \
              --enable-extended \
	      --prefix=$(rust_dest) \
              --sysconfdir=$(rust_dest)/etc \
              --localstatedir=$(rust_dest)/var/lib \
              --datadir=$(rust_dest)/share \
              --infodir=$(rust_dest)/share/info \
              --default-linker=gcc \
              --llvm-root=$(llvm_dest) \
              --enable-llvm-link-shared
	cd $(rust_src) && make
	cd $(rust_src) && make install
error: internal compiler error: src/librustc/ty/context.rs:237: node unknown node (id=1) with HirId::owner DefId { krate: CrateNum(0), node: DefIndex(0) => core/a38a63e } cannot be placed in TypeckTables with local_id_root DefId { krate: CrateNum(0), node: DefIndex(1533) => core/a38a63e::panicking[0]::panic_fmt[0] }

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.21.0-dev (41193c16f 2017-08-18) running on x86_64-unknown-linux-gnu

note: run with `RUST_BACKTRACE=1` for a backtrace

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:486:8
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:71
   2: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:60
   3: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:381
   4: std::panicking::default_hook
             at src/libstd/panicking.rs:391
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:611
   6: std::panicking::begin_panic
             at ./src/libstd/panicking.rs:572
   7: rustc_errors::Handler::bug
             at src/librustc_errors/lib.rs:486
   8: rustc::session::opt_span_bug_fmt::{{closure}}
             at src/librustc/session/mod.rs:852
   9: rustc::ty::context::tls::with_opt::{{closure}}
             at src/librustc/ty/context.rs:1289
  10: rustc::ty::context::tls::with::{{closure}}
             at src/librustc/ty/context.rs:1278
  11: <std::thread::local::LocalKey<T>>::try_with
             at ./src/libstd/thread/local.rs:365
  12: <std::thread::local::LocalKey<T>>::with
             at ./src/libstd/thread/local.rs:279
  13: rustc::ty::context::tls::with
             at src/librustc/ty/context.rs:1274
  14: rustc::ty::context::tls::with_opt
             at src/librustc/ty/context.rs:1289
  15: rustc::session::opt_span_bug_fmt
             at src/librustc/session/mod.rs:848
  16: rustc::session::bug_fmt
             at src/librustc/session/mod.rs:832
  17: rustc::ty::context::validate_hir_id_for_typeck_tables::{{closure}}
             at src/librustc/ty/context.rs:237
  18: rustc::ty::context::tls::with::{{closure}}
             at src/librustc/ty/context.rs:1278
  19: <std::thread::local::LocalKey<T>>::try_with
             at ./src/libstd/thread/local.rs:365
  20: <std::thread::local::LocalKey<T>>::with
             at ./src/libstd/thread/local.rs:279
  21: rustc::ty::context::tls::with
             at src/librustc/ty/context.rs:1274
  22: rustc::ty::context::validate_hir_id_for_typeck_tables
             at src/librustc/ty/context.rs:232
  23: rustc::ty::context::TypeckTables::node_id_to_type_opt
             at src/librustc/ty/context.rs:448
  24: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O>>::process_formals
             at src/librustc_save_analysis/dump_visitor.rs:322
  25: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O> as syntax::visit::Visitor<'l>>::visit_foreign_item::{{closure}}
             at src/librustc_save_analysis/dump_visitor.rs:1518
  26: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O>>::nest_tables
             at src/librustc_save_analysis/dump_visitor.rs:115
  27: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O> as syntax::visit::Visitor<'l>>::visit_foreign_item
             at src/librustc_save_analysis/dump_visitor.rs:1518
  28: syntax::visit::walk_item
             at ./src/libsyntax/visit.rs:146
  29: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O> as syntax::visit::Visitor<'l>>::visit_item
             at src/librustc_save_analysis/dump_visitor.rs:1254
  30: syntax::visit::walk_stmt
             at ./src/libsyntax/visit.rs:624
  31: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O> as syntax::visit::Visitor<'l>>::visit_stmt
             at src/librustc_save_analysis/dump_visitor.rs:1499
  32: syntax::visit::walk_block
             at ./src/libsyntax/visit.rs:146
  33: syntax::visit::Visitor::visit_block
             at ./src/libsyntax/visit.rs:66
  34: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O>>::process_fn::{{closure}}::{{closure}}
             at src/librustc_save_analysis/dump_visitor.rs:464
  35: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O>>::nest_scope
             at src/librustc_save_analysis/dump_visitor.rs:100
  36: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O>>::process_fn::{{closure}}
             at src/librustc_save_analysis/dump_visitor.rs:464
  37: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O>>::nest_tables
             at src/librustc_save_analysis/dump_visitor.rs:112
  38: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O>>::process_fn
             at src/librustc_save_analysis/dump_visitor.rs:464
  39: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O> as syntax::visit::Visitor<'l>>::visit_item
             at src/librustc_save_analysis/dump_visitor.rs:1206
  40: syntax::visit::walk_mod
             at ./src/libsyntax/visit.rs:146
  41: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O> as syntax::visit::Visitor<'l>>::visit_item::{{closure}}
             at src/librustc_save_analysis/dump_visitor.rs:1224
  42: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O>>::nest_scope
             at src/librustc_save_analysis/dump_visitor.rs:100
  43: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O> as syntax::visit::Visitor<'l>>::visit_item
             at src/librustc_save_analysis/dump_visitor.rs:1224
  44: syntax::visit::walk_mod
             at ./src/libsyntax/visit.rs:146
  45: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O> as syntax::visit::Visitor<'l>>::visit_mod::{{closure}}
             at src/librustc_save_analysis/dump_visitor.rs:1111
  46: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O>>::nest_scope
             at src/librustc_save_analysis/dump_visitor.rs:100
  47: <rustc_save_analysis::dump_visitor::DumpVisitor<'l, 'tcx, 'll, O> as syntax::visit::Visitor<'l>>::visit_mod
             at src/librustc_save_analysis/dump_visitor.rs:1111
  48: syntax::visit::walk_crate
             at ./src/libsyntax/visit.rs:180
  49: <rustc_save_analysis::DumpHandler<'a> as rustc_save_analysis::SaveHandler>::save
             at src/librustc_save_analysis/lib.rs:939
  50: rustc_save_analysis::process_crate
             at ./src/librustc_save_analysis/lib.rs:986
  51: rustc_driver::enable_save_analysis::{{closure}}::{{closure}}
             at src/librustc_driver/lib.rs:697
  52: rustc::util::common::time
             at ./src/librustc/util/common.rs:48
  53: rustc_driver::enable_save_analysis::{{closure}}
             at src/librustc_driver/lib.rs:696
  54: rustc_driver::driver::compile_input::{{closure}}
             at src/librustc_driver/driver.rs:217
  55: rustc_driver::driver::phase_3_run_analysis_passes::{{closure}}
             at src/librustc_driver/driver.rs:1101
  56: rustc::ty::context::tls::enter::{{closure}}
             at ./src/librustc/ty/context.rs:1262
  57: <std::thread::local::LocalKey<T>>::try_with
             at ./src/libstd/thread/local.rs:365
  58: <std::thread::local::LocalKey<T>>::with
             at ./src/libstd/thread/local.rs:279
  59: rustc::ty::context::tls::enter
             at ./src/librustc/ty/context.rs:1259
  60: rustc::ty::context::tls::enter_global::{{closure}}
             at ./src/librustc/ty/context.rs:1246
  61: <std::thread::local::LocalKey<T>>::try_with
             at ./src/libstd/thread/local.rs:365
  62: <std::thread::local::LocalKey<T>>::with
             at ./src/libstd/thread/local.rs:279
  63: rustc::ty::context::tls::enter_global
             at ./src/librustc/ty/context.rs:1243
  64: rustc::ty::context::TyCtxt::create_and_enter
             at ./src/librustc/ty/context.rs:1024
  65: rustc_driver::driver::phase_3_run_analysis_passes
             at src/librustc_driver/driver.rs:1014
  66: rustc_driver::driver::compile_input
             at src/librustc_driver/driver.rs:196
  67: rustc_driver::run_compiler
             at src/librustc_driver/lib.rs:316
  68: rustc_driver::main::{{closure}}
             at src/librustc_driver/lib.rs:1338
  69: rustc_driver::run::{{closure}}
             at src/librustc_driver/lib.rs:132
  70: rustc_driver::monitor::{{closure}}
             at src/librustc_driver/lib.rs:1255

error: Could not compile `core`.

Caused by:
  process didn't exit successfully: `/home/dvc/repos/riscv-rust/rust/build/bootstrap/debug/rustc --crate-name core src/libcore/lib.rs --error-format json --crate-type lib --emit=dep-info,link -C debug-assertions=off -C overflow-checks=on -C metadata=0f4c6fa20e4370e3 -C extra-filename=-0f4c6fa20e4370e3 --out-dir /home/dvc/repos/riscv-rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/debug/deps --target x86_64-unknown-linux-gnu -L dependency=/home/dvc/repos/riscv-rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/debug/deps -L dependency=/home/dvc/repos/riscv-rust/rust/build/x86_64-unknown-linux-gnu/stage1-std/debug/deps` (exit code: 101)
thread 'main' panicked at 'command did not execute successfully: "/home/dvc/repos/riscv-rust/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "-j" "4" "--target" "x86_64-unknown-linux-gnu" "--features" "panic-unwind debug-jemalloc jemalloc backtrace" "--manifest-path" "/home/dvc/repos/riscv-rust/rust/src/libstd/Cargo.toml" "--message-format" "json"
expected success, got: exit code: 101', src/bootstrap/compile.rs:869:8
stack backtrace:
   0: std::sys::imp::backtrace::tracing::imp::unwind_backtrace
             at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::_print
             at /checkout/src/libstd/sys_common/backtrace.rs:71
   2: std::panicking::default_hook::{{closure}}
             at /checkout/src/libstd/sys_common/backtrace.rs:60
             at /checkout/src/libstd/panicking.rs:380
   3: std::panicking::default_hook
             at /checkout/src/libstd/panicking.rs:396
   4: std::panicking::rust_panic_with_hook
             at /checkout/src/libstd/panicking.rs:611
   5: std::panicking::begin_panic_new
             at /checkout/src/libstd/panicking.rs:553
   6: std::panicking::begin_panic_fmt
             at /checkout/src/libstd/panicking.rs:521
   7: bootstrap::compile::run_cargo
   8: <bootstrap::compile::Std as bootstrap::builder::Step>::run
   9: bootstrap::builder::Builder::ensure
  10: <bootstrap::compile::Test as bootstrap::builder::Step>::run
  11: bootstrap::builder::Builder::ensure
  12: <bootstrap::compile::Rustc as bootstrap::builder::Step>::run
  13: bootstrap::builder::Builder::ensure
  14: <bootstrap::compile::Assemble as bootstrap::builder::Step>::run
  15: bootstrap::builder::Builder::ensure
  16: bootstrap::builder::Builder::compiler
  17: <bootstrap::compile::Std as bootstrap::builder::Step>::make_run
  18: bootstrap::builder::StepDescription::maybe_run
  19: bootstrap::builder::StepDescription::run
  20: bootstrap::builder::Builder::run
  21: bootstrap::Build::build
  22: bootstrap::main
  23: __rust_maybe_catch_panic
             at /checkout/src/libpanic_unwind/lib.rs:98
  24: std::rt::lang_start
             at /checkout/src/libstd/panicking.rs:458
             at /checkout/src/libstd/panic.rs:361
             at /checkout/src/libstd/rt.rs:59
  25: main
  26: __libc_start_main
  27: _start
failed to run: /home/dvc/repos/riscv-rust/rust/build/bootstrap/debug/bootstrap build
@Mark-Simulacrum Mark-Simulacrum 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 Aug 20, 2017
@jessicah
Copy link
Contributor

jessicah commented Sep 7, 2017

Just hit this myself. It only happens in my builds if I pass --enable-extended to configure script for my CI container. Running with and without each time from a clean obj directory.

Note that it does need to be a clean build when changing --enable-extended. This does not happen if I start without --enable-extended then rebuilding with it added with existing build artefacts present.

At commit a209539

@cuviper
Copy link
Member

cuviper commented Sep 8, 2017

Ping @michaelwoerister, since you wrote commit 783ccc4 implicated in OP, any ideas?

@michaelwoerister
Copy link
Member

Hm, looks like the DumpVisitor in save-analysis doesn't update its TypeckTables correctly as it traverses the AST. I'll take a closer look next week.

@jld
Copy link
Contributor

jld commented Sep 16, 2017

I just ran into this trying to run the CI container build for FreeBSD, to investigate #44433. I worked around it for now by removing --enable-extended, but I'm a little confused, because according to the list of platforms x86_64-unknown-freebsd is Tier 2 and build breakages won't land, which would mean that there's something different about my local setup that's observable inside the container and relevant to this part of rustc.

@oli-obk
Copy link
Contributor

oli-obk commented Dec 20, 2017

ping @michaelwoerister I just ran into this

@michaelwoerister
Copy link
Member

Maybe @nrc can help debug this? It seems that in DumpVisitor::process_formals(), one of the collected_idents (with NodeId=1) is something that is not actually part of the function being visited, thus triggering an assertion when we try to look up the type of that node. It looks valid to me that the assertion is triggered. But it's strange that the PathCollector there should find that node. Are NodeIds in the AST reliable?

@mcandre
Copy link

mcandre commented Dec 31, 2017

Note that it does need to be a clean build when changing --enable-extended. This does not happen if I start without --enable-extended then rebuilding with it added with existing build artefacts present.

How can NetBSD users inject the --enable-extended flag for installing rust via pkgsrc? I'm getting the same exit 101 error with su root -c "cd /usr/pkgsrc/lang/rust && sudo make install PKG_OPTIONS.python27=-x11".

As a workaround, I'm using rustup to install rustc and cargo in NetBSD, now that rustup features support for the NetBSD kernel :)

@nrc
Copy link
Member

nrc commented Jan 12, 2018

Does anyone have a minimal test case for this?

That NodeId=1 seems suspicious, it would be good to see the source code where this happened to get some idea about what is going on. Maybe it is a synthetic argument for a self argument? It would have to be some weird edge case, or I'd think we'd hit this a lot.

@jonas-schievink
Copy link
Contributor

#63663 seems like it has an easy reproduction

@jonas-schievink
Copy link
Contributor

Nominating. This has been reported at least 6 times, and is being hit in random PR builds too.

@nikomatsakis
Copy link
Contributor

Visiting for compiler triage.

This problems seems to be closely tied to save-analysis, correct? @Xanewok, maybe you can investigate, and ping @michaelwoerister for help where needed?

@nikomatsakis nikomatsakis added P-high High priority and removed I-nominated labels Aug 29, 2019
@nikomatsakis
Copy link
Contributor

Marking P-high and assigning to @Xanewok, because I'm optimistic like that.

@Xanewok
Copy link
Member

Xanewok commented Sep 5, 2019

This looks strikingly similar to #60649 where we didn't nest typeck tables in the AST visitor.

In this case it's visit_foreign_item > process_formals so hopefully we can reproduce that on source such as

extern { fn func(arg: SomeType); }

@Xanewok
Copy link
Member

Xanewok commented Sep 5, 2019

The backtrace in the OP is outdated or at least that's not the issue I first encountered.

In general it seems that generating save-analysis from libcore triggers a debug-assertion (which is why it came up recently when running dist builds with -C debug-assertions=y).

I managed to reproduce it with:

# config.toml
[build]
extended = true
[rust]
debug-assertions = true
tools = ["analysis"]

by running
$ RUSTC_SAVE_ANALYSIS=api ./x.py build

The current backtrace I'm getting is as follows:

[...]
   Compiling core v0.0.0 (/home/xanewok/repos/rust/src/libcore)
error: internal compiler error: src/librustc/ty/context.rs:214: node type <T>::IntoIter (hir_id=HirId { owner: DefIndex(4040), local_id: 61 }) with HirId::owner DefId(0:4040 ~ core[db27]::iter[0]::adapters[0]::flatten[0]::{{impl}}[13]::try_fold[0]::flatten[0]) cannot be placed in TypeckTables with local_id_root DefId(0:4036 ~ core[db27]::iter[0]::adapters[0]::flatten[0]::{{impl}}[13]::try_fold[0])

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:643:9
stack backtrace:
   0:     0x7fcfb9b9fa82 - std::sys_common::backtrace::print::h3ccd05a8e990e9b0
   1:     0x7fcfb9bafc82 - std::panicking::default_hook::{{closure}}::h2c2369fef3dd8738
   2:     0x7fcfb9baf9f4 - std::panicking::default_hook::h5593167b5f202307
   3:     0x7fcfbc8f07d1 - rustc::util::common::panic_hook::h7cdff5d1edfec23a
   4:     0x7fcfb9bb066e - std::panicking::rust_panic_with_hook::he0d392b5db3b1393
   5:     0x7fcfbce3b83d - std::panicking::begin_panic::hed9199d93294adf2
   6:     0x7fcfbce64fff - rustc_errors::Handler::bug::hcdd16ef9af0b70a5
   7:     0x7fcfbc417ac8 - rustc::util::bug::opt_span_bug_fmt::{{closure}}::h172f1a229254071a
   8:     0x7fcfbc412f13 - rustc::ty::context::tls::with_opt::{{closure}}::h20b6cc14b4d4ee22
   9:     0x7fcfbc412e83 - rustc::ty::context::tls::with_context_opt::h4b93cd0baf1cf64c
  10:     0x7fcfbc412ec7 - rustc::ty::context::tls::with_opt::h59612e3fe61d9a6e
  11:     0x7fcfbc4179b8 - rustc::util::bug::opt_span_bug_fmt::h0bcb131f0ef383f3
  12:     0x7fcfbc417922 - rustc::util::bug::bug_fmt::h9efce7ee2f38ac34
  13:     0x7fcfbc753786 - rustc::ty::context::validate_hir_id_for_typeck_tables::{{closure}}::h40b9c9909894d5c5
  14:     0x7fcfbc76c389 - rustc::ty::context::tls::with::{{closure}}::hdfea32d74f0e82f7
  15:     0x7fcfbc76c360 - rustc::ty::context::tls::with_context::{{closure}}::h375e4279d6f7e516
  16:     0x7fcfbc76ae28 - rustc::ty::context::tls::with_context_opt::h2c26a79a9d51d01f
  17:     0x7fcfbc76ae36 - rustc::ty::context::tls::with_context::h472f2429318db06e
  18:     0x7fcfbc76c376 - rustc::ty::context::tls::with::h3db787a9be2b7222
  19:     0x7fcfbc7545fe - rustc::ty::context::TypeckTables::qpath_res::h64f4550ee1debf16
  20:     0x7fcfbb96c6bf - rustc_save_analysis::SaveContext::get_path_res::h75df113a150104f7
  21:     0x7fcfbb9d7c2d - <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_ty::h2f81ec7e83d8985e
  22:     0x7fcfbb9bface - syntax::visit::walk_generic_args::h5060edf426757671
  23:     0x7fcfbb9d7dc1 - <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_ty::h2f81ec7e83d8985e
  24:     0x7fcfbb9c16ac - syntax::visit::walk_ty::h037aa9d3b0ff40c2
  25:     0x7fcfbb9d46db - <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_item::h7784b50029a7c2b4
  26:     0x7fcfbb9cb83e - rustc_save_analysis::dump_visitor::DumpVisitor::process_method::h229a40ba297088ca
  27:     0x7fcfbb9d4408 - <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_item::h7784b50029a7c2b4
  28:     0x7fcfbb9d1c6a - <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_item::h7784b50029a7c2b4
  29:     0x7fcfbb9d1c6a - <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_item::h7784b50029a7c2b4
  30:     0x7fcfbb9d1c6a - <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_item::h7784b50029a7c2b4
  31:     0x7fcfbb9d0a2a - <rustc_save_analysis::dump_visitor::DumpVisitor as syntax::visit::Visitor>::visit_mod::h054a0b766f054540
  32:     0x7fcfba237b16 - syntax::visit::walk_crate::hfd3f86321d89f575
  33:     0x7fcfba18ba3b - rustc::dep_graph::graph::DepGraph::with_ignore::hc4aceef6921b5d51
  34:     0x7fcfba24e938 - rustc_save_analysis::process_crate::h209b10f593ffc88a
  35:     0x7fcfba195a23 - rustc_driver::run_compiler::{{closure}}::{{closure}}::{{closure}}::h22fe8b90cef236c4
  36:     0x7fcfba18af91 - rustc::util::common::time::hc42a40104d377b36
  37:     0x7fcfba1d1d1d - rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}::had5d7435a68c899b
  38:     0x7fcfba3cdb8a - rustc_interface::passes::create_global_ctxt::{{closure}}::hacffd98af6b4442e
  39:     0x7fcfba1d38d2 - rustc_interface::interface::run_compiler_in_existing_thread_pool::h53d03c09ad272798
  40:     0x7fcfba1e96b1 - std::thread::local::LocalKey<T>::with::h9154d3730506d959
  41:     0x7fcfba205a55 - scoped_tls::ScopedKey<T>::set::h369df4d9d9aa6258
  42:     0x7fcfba237952 - syntax::with_globals::h8b475ba4fa6aace5
  43:     0x7fcfba1b306d - std::sys_common::backtrace::__rust_begin_short_backtrace::hc7aee0ada2eefdd2
  44:     0x7fcfba1b5b5e - std::panicking::try::do_call::h001c18685067ae4f
  45:     0x7fcfb9bb1cd4 - __rust_maybe_catch_panic
  46:     0x7fcfba1b5a9a - std::panicking::try::he4318e326d9619df
  47:     0x7fcfba1bd4ee - core::ops::function::FnOnce::call_once{{vtable.shim}}::h8e5aa07c722a4072
  48:     0x7fcfb9ba841f - <alloc::boxed::Box<F> as core::ops::function::FnOnce<A>>::call_once::hbd9c620013ca32c8
  49:     0x7fcfb9bb0f60 - std::sys::unix::thread::Thread::new::thread_start::h081abdb0058386a4
  50:     0x7fcfb904a6db - start_thread
  51:     0x7fcfb984788f - __clone
  52:                0x0 - <unknown>
query stack during panic:
end of query stack
error: aborting due to previous error


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.39.0-dev running on x86_64-unknown-linux-gnu

note: compiler flags: -Z binary-dep-depinfo -Z external-macro-backtrace -Z save-analysis -Z force-unstable-if-unmarked -C opt-level=2 -C debuginfo=0 -C prefer-dynamic -C debug-assertions=y -C link-args=-Wl,-rpath,$ORIGIN/../lib --crate-type lib

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

error: Could not compile `core`.

To learn more, run the command again with --verbose.
command did not execute successfully: "/home/xanewok/repos/rust/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "12" "--release" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/home/xanewok/repos/rust/src/libtest/Cargo.toml" "--message-format" "json-render-diagnostics"
expected success, got: exit code: 101
failed to run: /home/xanewok/repos/rust/build/bootstrap/debug/bootstrap build

on most recent master

which I believe stumbles on

#[inline]
fn try_fold<Acc, Fold, R>(&mut self, mut init: Acc, mut fold: Fold) -> R where
Self: Sized, Fold: FnMut(Acc, Self::Item) -> R, R: Try<Ok=Acc>
{
#[inline]
fn flatten<'a, T: IntoIterator, Acc, R: Try<Ok = Acc>>(
frontiter: &'a mut Option<T::IntoIter>,
fold: &'a mut impl FnMut(Acc, T::Item) -> R,
) -> impl FnMut(Acc, T) -> R + 'a {
move |acc, x| {
let mut mid = x.into_iter();
let r = mid.try_fold(acc, &mut *fold);
*frontiter = Some(mid);
r
}
}

most specifically when processing the associated T::IntoIter (IIUC the typeck tables are not nested correctly somehow)

@Xanewok
Copy link
Member

Xanewok commented Sep 6, 2019

With debug_assertions-enabled rustc, I managed to minimize the reproduction case when generating save-analysis to

pub trait Trait {
    type Assoc;
}

pub fn func() {
    fn _inner<U: Trait>(_: U::Assoc) {}
}

tmandry added a commit to tmandry/rust that referenced this issue Sep 10, 2019
… r=varkor

save-analysis: Nest typeck tables when processing functions/methods

Fixes an issue where we did not nest tables correctly when resolving
associated types in formal argument/return type positions.

This was the minimized reproduction case that I tested the fix on:
```rust
pub trait Trait {
    type Assoc;
}

pub struct A;

pub fn func() {
    fn _inner1<U: Trait>(_: U::Assoc) {}
    fn _inner2<U: Trait>() -> U::Assoc { unimplemented!() }

    impl A {
        fn _inner1<U: Trait>(self, _: U::Assoc) {}
        fn _inner2<U: Trait>(self) -> U::Assoc { unimplemented!() }
    }
}
```
using `debug_assertions`-enabled rustc and by additionally passing `-Zsave-analysis`.

Unfortunately the original assertion fired is a *debug* one and from what I can tell we don't run the tests with these on, so I'm not adding a test here. If I missed it and there is a way to run tests with these on, I'd love to add a test case for this.

Closes rust-lang#63663
Closes rust-lang#50328
Closes rust-lang#43982
@bors bors closed this as completed in 2e11e81 Sep 16, 2019
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. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-high High priority T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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.