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

Internal compiler error: can't buffer lints after HIR lowering #65253

Closed
dingelish opened this issue Oct 9, 2019 · 7 comments · Fixed by #65283
Closed

Internal compiler error: can't buffer lints after HIR lowering #65253

dingelish opened this issue Oct 9, 2019 · 7 comments · Fixed by #65283
Assignees
Labels
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) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@dingelish
Copy link
Contributor

Hi there,

I'm updating rust-sgx-sdk (solving rust-sgx-sdk #161) to use latest rust nightly compiler to help the error info more ergonomic by the help of #60561. However, the compiler always panics. Your help would be very much helpful.

The current code is at https://github.com/baidu/rust-sgx-sdk/tree/librustc-bug-report . To reproduce this bug, please checkout branch librustc-bug-report and build sgx_tstd as follows:

git clone https://github.com/baidu/rust-sgx-sdk.git --branch librustc-bug-report
cd sgx_tstd
cargo build

And the reproducible failure info is:

error: internal compiler error: src/librustc/session/mod.rs:379: can't buffer lints after HIR lowering

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:915:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

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.40.0-nightly (032a53a06 2019-10-03) running on x86_64-unknown-linux-gnu

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

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

error: aborting due to previous error

error: could not compile `sgx_tstd`.

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

Meta

rustc --version --verbose:
rustc 1.40.0-nightly (032a53a 2019-10-03)
binary: rustc
commit-hash: 032a53a
commit-date: 2019-10-03
host: x86_64-unknown-linux-gnu
release: 1.40.0-nightly
LLVM version: 9.0

Backtrace:

     Running `rustc --edition=2018 --crate-name sgx_tstd src/lib.rs --color always --crate-type rlib --emit=dep-info,metadata,link -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="stdio"' -C metadata=efa82b20f3ba8732 -C extra-filename=-efa82b20f3ba8732 --out-dir /home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps -C incremental=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/incremental -L dependency=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps --extern sgx_alloc=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_alloc-ad20d7e0fe6e7e8f.rmeta --extern sgx_backtrace_sys=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_backtrace_sys-fb71f2a27217c86f.rmeta --extern sgx_demangle=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_demangle-7efcf1000ae681fd.rmeta --extern sgx_libc=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_libc-c007d9004d6eb876.rmeta --extern sgx_tprotected_fs=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_tprotected_fs-1993701cdf0742cc.rmeta --extern sgx_trts=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_trts-4601b4cac7f4f271.rmeta --extern sgx_types=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_types-e6e7a9a7cef74d06.rmeta --extern sgx_unwind=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_unwind-f3194af852ce8a4e.rmeta -L native=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/build/sgx_backtrace_sys-d202fe026b4e22c7/out/libbacktrace/ -L native=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/build/sgx_backtrace_sys-d202fe026b4e22c7/out/libbacktrace -L native=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/build/sgx_unwind-cde3a2cab833ed9c/out/libunwind/src/.libs`
error: internal compiler error: src/librustc/session/mod.rs:379: can't buffer lints after HIR lowering

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:915:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:76
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:60
   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:64
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:49
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:196
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:210
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:477
  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::session::Session::buffer_lint
  22: rustc::middle::stability::report_unstable
  23: rustc::middle::stability::<impl rustc::ty::context::TyCtxt>::check_stability
  24: rustc::hir::intravisit::walk_item
  25: <rustc::middle::stability::Checker as rustc::hir::intravisit::Visitor>::visit_item
  26: rustc::middle::stability::check_mod_unstable_api_usage
  27: rustc::ty::query::__query_compute::check_mod_unstable_api_usage
  28: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::check_mod_unstable_api_usage>::compute
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  31: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  32: <std::panic::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
  33: __rust_maybe_catch_panic
             at src/libpanic_unwind/lib.rs:80
  34: rustc_interface::passes::analysis::{{closure}}
  35: rustc::util::common::time
  36: rustc_interface::passes::analysis
  37: rustc::ty::query::__query_compute::analysis
  38: rustc::dep_graph::graph::DepGraph::with_task_impl
  39: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  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: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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.40.0-nightly (032a53a06 2019-10-03) running on x86_64-unknown-linux-gnu

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

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

query stack during panic:
#0 [check_mod_unstable_api_usage] checking for unstable API usage in module `prelude::v1`
#1 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

error: could not compile `sgx_tstd`.

Caused by:
  process didn't exit successfully: `rustc --edition=2018 --crate-name sgx_tstd src/lib.rs --color always --crate-type rlib --emit=dep-info,metadata,link -C debuginfo=2 --cfg 'feature="default"' --cfg 'feature="stdio"' -C metadata=efa82b20f3ba8732 -C extra-filename=-efa82b20f3ba8732 --out-dir /home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps -C incremental=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/incremental -L dependency=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps --extern sgx_alloc=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_alloc-ad20d7e0fe6e7e8f.rmeta --extern sgx_backtrace_sys=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_backtrace_sys-fb71f2a27217c86f.rmeta --extern sgx_demangle=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_demangle-7efcf1000ae681fd.rmeta --extern sgx_libc=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_libc-c007d9004d6eb876.rmeta --extern sgx_tprotected_fs=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_tprotected_fs-1993701cdf0742cc.rmeta --extern sgx_trts=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_trts-4601b4cac7f4f271.rmeta --extern sgx_types=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_types-e6e7a9a7cef74d06.rmeta --extern sgx_unwind=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/deps/libsgx_unwind-f3194af852ce8a4e.rmeta -L native=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/build/sgx_backtrace_sys-d202fe026b4e22c7/out/libbacktrace/ -L native=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/build/sgx_backtrace_sys-d202fe026b4e22c7/out/libbacktrace -L native=/home/ding/rust-sgx-sdk/sgx_tstd/target/debug/build/sgx_unwind-cde3a2cab833ed9c/out/libunwind/src/.libs` (exit code: 101)
@Mark-Simulacrum Mark-Simulacrum added 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) ❄️ labels Oct 10, 2019
@Mark-Simulacrum
Copy link
Member

It'd be helpful to have a more minimal example here I suspect -- for example, at least reducing to a single crate.

cc @estebank since this deals with diagnostic machinery

@estebank
Copy link
Contributor

It seems like this was introduced a month ago in #64066, f7434ae#diff-fe6fbe1c488f33762a812dfee7e5e919R509-R515

CC @petrochenkov

@dingelish
Copy link
Contributor Author

I think I find the solution on my side: the removal of #[doc(no_inline)] pub use core::prelude::v1::bench.

@dingelish
Copy link
Contributor Author

dingelish commented Oct 10, 2019

apache/incubator-teaclave-sgx-sdk@librustc-bug-report...test-2019-10

A working branch is baidu/rust-sgx-sdk : test-2019-10.
Failing branch is librustc-bug-report.

After I enable this line, the compiler starts to fail.

@dingelish
Copy link
Contributor Author

The minimum sample is as follows:

#![no_std]

pub use core::prelude::v1::bench;

and compile by

rustc --crate-type rlib fail.rs

@petrochenkov petrochenkov self-assigned this Oct 10, 2019
@jonas-schievink jonas-schievink added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 10, 2019
@petrochenkov
Copy link
Contributor

Fixed in #65283.

@dingelish
Copy link
Contributor Author

Cool!

tmandry added a commit to tmandry/rust that referenced this issue Oct 11, 2019
stability: Do not use `buffer_lint` after lowering to HIR

Fixes rust-lang#65253
tmandry added a commit to tmandry/rust that referenced this issue Oct 11, 2019
stability: Do not use `buffer_lint` after lowering to HIR

Fixes rust-lang#65253
Centril added a commit to Centril/rust that referenced this issue Oct 11, 2019
stability: Do not use `buffer_lint` after lowering to HIR

Fixes rust-lang#65253
@bors bors closed this as completed in 976a57a Oct 12, 2019
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-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) ❄️ 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