Getting ICE on the most basic runs of cargo clippy after upgrading to 1.34. In rand??
This is on Windows 10.
error: internal compiler error: src\librustc_mir\monomorphize\collector.rs:745: Cannot create local mono-item for DefId(12/0:117 ~ rand_core[8332]::{{impl}}[0]::try_fill_bytes[0])
thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:620:9
stack backtrace:
0: std::sys_common::alloc::realloc_fallback
1: std::panicking::take_hook
2: std::panicking::take_hook
3: <rustc::ty::sty::Binder<rustc::ty::ProjectionPredicate<'tcx>> as rustc::ty::ToPredicate<'tcx>>::to_predicate
4: std::panicking::rust_panic_with_hook
5: <rustc_errors::emitter::ColorConfig as core::fmt::Debug>::fmt
6: rustc_errors::Handler::bug
7: rustc::util::bug::bug_fmt
8: rustc::ty::wf::object_region_bounds
9: rustc::ty::wf::object_region_bounds
10: rustc::ty::wf::object_region_bounds
11: rustc::util::bug::bug_fmt
12: rustc::util::bug::bug_fmt
13: <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_static
14: <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_static
15: <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind
16: rustc_mir::monomorphize::collector::collect_crate_mono_items
17: rustc_mir::monomorphize::collector::collect_crate_mono_items
18: <rustc_mir::transform::generator::StateTransform as rustc_mir::transform::MirPass>::run_pass
19: <rustc_mir::interpret::eval_context::StackPopCleanup as core::fmt::Debug>::fmt
20: rustc_mir::monomorphize::collector::collect_crate_mono_items
21: <rustc_mir::interpret::eval_context::StackPopCleanup as core::fmt::Debug>::fmt
22: rustc_mir::monomorphize::partitioning::compute_codegen_unit_name
23: <rustc_codegen_ssa::common::TypeKind as core::fmt::Debug>::fmt
24: <rustc_codegen_ssa::MemFlags as core::fmt::UpperHex>::fmt
25: <rustc_codegen_ssa::MemFlags as core::fmt::UpperHex>::fmt
26: <rustc_codegen_ssa::MemFlags as core::fmt::UpperHex>::fmt
27: rustc_codegen_ssa::back::archive::find_library
28: <rustc_codegen_llvm::back::lto::ThinLTOImports as core::fmt::Debug>::fmt
29: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::join_codegen_and_link
30: <rustc_codegen_llvm::llvm_::ffi::PassKind as core::fmt::Debug>::fmt
31: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::join_codegen_and_link
32: <rustc_codegen_llvm::back::link::exec_linker::Escape<'a> as core::fmt::Display>::fmt
33: rustc_codegen_llvm::consts::<impl rustc_codegen_ssa::traits::statics::StaticMethods for rustc_codegen_llvm::context::CodegenCx<'ll, 'tcx>>::codegen_static
34: rustc_codegen_llvm::llvm_::diagnostic::Diagnostic::unpack
35: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
36: rand::os::OsRng::new
37: rustc_driver::driver::phase_4_codegen
38: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
39: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
40: <env_logger::fmt::WriteStyle as core::default::Default>::default
41: rustc_driver::driver::compile_input
42: rustc_driver::run_compiler
43: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
44: rustc_driver::run_compiler
45: <unknown>
46: <unknown>
47: _rust_maybe_catch_panic
48: <unknown>
49: std::sys::windows::thread::Thread::new
50: BaseThreadInitThunk
51: RtlUserThreadStart
query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
#1 [backend_optimization_level] optimization level used by backend
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.34.0 (91856ed52 2019-04-10) running on x86_64-pc-windows-msvc
note: compiler flags: -C debuginfo=2 -C linker=lld-link.exe -C link-args=-fuse-ld=lld -C opt-level=z -C inline-threshold=275 -C lto=no --crate-type lib
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `rand`.
Do you have some code to share which reproduces the problem?
@rustbot modify labels: I-ICE T-compiler A-mir
Anything. As you can see, the clippy error happens in system libraries, not my code. I have tried to uninstall and reinstall the toolchain and clippy using rustup, same thing happens.
So, when you create a new project via cargo new foo, then cd into it and run cargo clippy it will give you the error above?
If I do cargo new foo, and then add rand = "0.6" under dependencies in foo/Cargo.toml, then do cargo clippy, the above happens.
cargo check also triggers it. But not cargo run, which works as expected.
I have to say, that I cannot reproduce it with a clean project (even after adding rand = "0.6" in Cargo.toml).
I think there's more here, but the error message looks like #59898
Yeah, looks like the same crash. It bizarrely reproduces 100% on one machine but not on others. Again, reinstalling toolchain etc has no effect.
Either way, I think the fix urgently needs to go into stable.
Yes, this is likely a duplicate, so closing in favor of #59898. It will be fixed in 1.34.1
This in fact still happens on Rust 1.34.1. Please re-open.
error: internal compiler error: src\librustc_mir\monomorphize\collector.rs:745: Cannot create local mono-item for DefId(11/0:14 ~ lazy_static[6522]::lazy[0]::{{impl}}[0]::get[0])
thread 'rustc' panicked at 'Box<Any>', src\librustc_errors\lib.rs:620:9
Checking matrixmultiply v0.2.2
warning: not embedding natvis: lld-link may not support the flag
stack backtrace:
0: std::sys_common::alloc::realloc_fallback
1: std::panicking::take_hook
2: std::panicking::take_hook
3: <rustc::ty::sty::Binder<rustc::ty::ProjectionPredicate<'tcx>> as rustc::ty::ToPredicate<'tcx>>::to_predicate
4: std::panicking::rust_panic_with_hook
5: <rustc_errors::emitter::ColorConfig as core::fmt::Debug>::fmt
6: rustc_errors::Handler::bug
7: rustc::util::bug::bug_fmt
8: rustc::ty::wf::object_region_bounds
9: rustc::ty::wf::object_region_bounds
10: rustc::ty::wf::object_region_bounds
11: rustc::util::bug::bug_fmt
12: rustc::util::bug::bug_fmt
13: <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_static
14: <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_static
15: <rustc_mir::monomorphize::collector::MirNeighborCollector<'a, 'tcx> as rustc::mir::visit::Visitor<'tcx>>::visit_terminator_kind
16: rustc_mir::monomorphize::collector::collect_crate_mono_items
17: rustc_mir::monomorphize::collector::collect_crate_mono_items
18: rustc_mir::monomorphize::collector::collect_crate_mono_items
19: rustc_mir::monomorphize::collector::collect_crate_mono_items
20: rustc_mir::monomorphize::collector::collect_crate_mono_items
21: rustc_mir::monomorphize::collector::collect_crate_mono_items
22: rustc_mir::monomorphize::collector::collect_crate_mono_items
23: rustc_mir::monomorphize::collector::collect_crate_mono_items
24: rustc_mir::monomorphize::collector::collect_crate_mono_items
25: <rustc_mir::transform::generator::StateTransform as rustc_mir::transform::MirPass>::run_pass
26: <rustc_mir::interpret::eval_context::StackPopCleanup as core::fmt::Debug>::fmt
27: rustc_mir::monomorphize::collector::collect_crate_mono_items
28: <rustc_mir::interpret::eval_context::StackPopCleanup as core::fmt::Debug>::fmt
29: rustc_mir::monomorphize::partitioning::compute_codegen_unit_name
30: <rustc_codegen_ssa::common::TypeKind as core::fmt::Debug>::fmt
31: <rustc_codegen_ssa::MemFlags as core::fmt::UpperHex>::fmt
32: <rustc_codegen_ssa::MemFlags as core::fmt::UpperHex>::fmt
33: <rustc_codegen_ssa::MemFlags as core::fmt::UpperHex>::fmt
34: rustc_codegen_ssa::back::archive::find_library
35: <rustc_codegen_llvm::back::lto::ThinLTOImports as core::fmt::Debug>::fmt
36: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::join_codegen_and_link
37: <rustc_codegen_llvm::llvm_::ffi::PassKind as core::fmt::Debug>::fmt
38: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::join_codegen_and_link
39: <rustc_codegen_llvm::back::link::exec_linker::Escape<'a> as core::fmt::Display>::fmt
40: rustc_codegen_llvm::consts::<impl rustc_codegen_ssa::traits::statics::StaticMethods for rustc_codegen_llvm::context::CodegenCx<'ll, 'tcx>>::codegen_static
41: rustc_codegen_llvm::llvm_::diagnostic::Diagnostic::unpack
42: <rustc_codegen_llvm::LlvmCodegenBackend as rustc_codegen_utils::codegen_backend::CodegenBackend>::codegen_crate
43: rand::os::OsRng::new
44: rustc_driver::driver::phase_4_codegen
45: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
46: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
47: <env_logger::fmt::WriteStyle as core::default::Default>::default
48: rustc_driver::driver::compile_input
49: rustc_driver::run_compiler
50: <rustc_driver::CompilationFailure as core::fmt::Debug>::fmt
51: rustc_driver::run_compiler
52: <unknown>
53: <unknown>
54: _rust_maybe_catch_panic
55: <unknown>
56: std::sys::windows::thread::Thread::new
57: BaseThreadInitThunk
58: RtlUserThreadStart
query stack during panic:
#0 [collect_and_partition_mono_items] collect_and_partition_mono_items
#1 [backend_optimization_level] optimization level used by backend
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.34.1 (fc50f328b 2019-04-24) running on x86_64-pc-windows-msvc
note: compiler flags: -C debuginfo=2 -C linker=lld-link.exe -C link-args=-fuse-ld=lld -C opt-level=z -C inline-threshold=275 -C lto=no --crate-type lib
note: some of the compiler flags provided by cargo are hidden
error: Could not compile `thread_local`.
@hrydgard The compiler team decided not to backport the fix for this issue. It is already fixed on beta and nightly and will be fixed in 1.35.0. I closed the issue because it is a duplicate of https://github.com/rust-lang/rust/issues/59898, however, which is still open.
@hrydgard can you please confirm that it has been fixed on beta by using rustup default beta; rustup update?
Yes, that's a good idea. The weird thing is that #59898 only really happens on crates that target non-tier1 platforms, so this might still be something else.
It appears to be fixed in beta for me.
Still, indeed mysterious that it doesn't seem to happen for others on Windows. If there's anything you'd want me to check about my installation, I'm happy to do so.
While fixed in beta, still seeing this on Rust stable 1.34.2, just for the record. I don't understand why it only happens on this one machine on Windows... What could possibly be different?
As Jonas said, it has not been back ported to stable. Beta branch will be 1.35, not the next 1.34.X, that are only hotfixes (in this case an unsound trait method)
Yeah, I'm not saying it's unexpected that it's not fixed 1.34.2, I'm saying it's very unexpected that no-one else seems to be hitting it.
I figured out why it's only happening to me on Windows.
I used the following ~/.cargo to speed up builds by linking using LLD:
[target.x86_64-pc-windows-msvc]
linker = "lld-link.exe"
rustflags = ["-C", "link-args=-fuse-ld=lld", "-C", "opt-level=z", "-C", "inline-threshold=275", "-C", "lto=no"]
The killer is opt-level="z", which triggers this problem. "s" does too, but not "2" for example.
Ah then that's the link between your setup and the embedded use cases that were hitting this.
Then this is certainly a dup of https://github.com/rust-lang/rust/issues/59898
Most helpful comment
I figured out why it's only happening to me on Windows.
I used the following ~/.cargo to speed up builds by linking using LLD:
The killer is opt-level="z", which triggers this problem. "s" does too, but not "2" for example.