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

ICE on stable due to messed up target/ directory #124179

Closed
jdonszelmann opened this issue Apr 19, 2024 · 7 comments
Closed

ICE on stable due to messed up target/ directory #124179

jdonszelmann opened this issue Apr 19, 2024 · 7 comments
Assignees
Labels
A-incr-comp Area: Incremental compilation 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.

Comments

@jdonszelmann
Copy link
Contributor

jdonszelmann commented Apr 19, 2024

Code

I've had this once before on a different project. Something causes target/ to get messed up (not me messing in target, rust does it on its own) and we get an ICE. It's almost impossible to reproduce. I'm just working in a large project and this specific target directory is messed up. cargo clean; cargo build fixes it. However, I still wanted to report it. I made a backup of my specific target directory for those interested. An immediate close is also fine. I guess one clue might be that it happened after I ran cargo fix for the first time in a while? But that seems to be unrelated.

(not including any rust code because I cannot minimize my example. It's just my specific target )

Meta

rustc --version --verbose:

rustc 1.77.2 (25ef9e3d8 2024-04-09)
binary: rustc
commit-hash: 25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04
commit-date: 2024-04-09
host: x86_64-unknown-linux-gnu
release: 1.77.2
LLVM version: 17.0.6

Error output

thread 'rustc' panicked at library/alloc/src/raw_vec.rs:570:5:
capacity overflow
stack backtrace:
   0:     0x7df3360bfd16 - std::backtrace_rs::backtrace::libunwind::trace::hd6ffdc229294c06f
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x7df3360bfd16 - std::backtrace_rs::backtrace::trace_unsynchronized::h991f79b6e9960513
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7df3360bfd16 - std::sys_common::backtrace::_print_fmt::hf4ebe716f7ccda10
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x7df3360bfd16 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h410d4c66be4e37f9
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x7df336112770 - core::fmt::rt::Argument::fmt::he0ff0e0e188c0db5
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/fmt/rt.rs:142:9
   5:     0x7df336112770 - core::fmt::write::he40921d4802ce2ac
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/fmt/mod.rs:1120:17
   6:     0x7df3360b361f - std::io::Write::write_fmt::h5de5a4e7037c9b20
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/io/mod.rs:1846:15
   7:     0x7df3360bfaf4 - std::sys_common::backtrace::_print::hd8e2e3f655086663
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x7df3360bfaf4 - std::sys_common::backtrace::print::h11c067a88e3bdb22
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x7df3360c2887 - std::panicking::default_hook::{{closure}}::h8c832ecb03fde8ea
  10:     0x7df3360c25e9 - std::panicking::default_hook::h1633e272b4150cf3
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:292:9
  11:     0x7df332fa0dac - std[85008a29cc0b7dba]::panicking::update_hook::<alloc[a3006b27d8562c00]::boxed::Box<rustc_driver_impl[7bf504f3f6583165]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x7df3360c2fd6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h4dd5cc3b5605ae1a
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/alloc/src/boxed.rs:2029:9
  13:     0x7df3360c2fd6 - std::panicking::rust_panic_with_hook::hb164d19c0c1e71d4
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:785:13
  14:     0x7df3360c2ce9 - std::panicking::begin_panic_handler::{{closure}}::h0369088c533c20e9
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:651:13
  15:     0x7df3360c0216 - std::sys_common::backtrace::__rust_end_short_backtrace::hc11d910daf35ac2e
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x7df3360c2a74 - rust_begin_unwind
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647:5
  17:     0x7df33610ee75 - core::panicking::panic_fmt::ha6effc2775a0749c
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72:14
  18:     0x7df3360ffdaf - alloc::raw_vec::capacity_overflow::hbca7785f3bc15d50
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/alloc/src/raw_vec.rs:570:5
  19:     0x7df3351f744e - rustc_incremental[7cd4159165d3d39c]::persist::load::setup_dep_graph
  20:     0x7df335146c6e - <rustc_interface[80a0b631737fb765]::queries::Queries>::global_ctxt
  21:     0x7df334ee602e - rustc_interface[80a0b631737fb765]::interface::run_compiler::<core[7fef78d3beba6ff5]::result::Result<(), rustc_span[865b327b21456c24]::ErrorGuaranteed>, rustc_driver_impl[7bf504f3f6583165]::run_compiler::{closure#0}>::{closure#0}
  22:     0x7df335133df1 - std[85008a29cc0b7dba]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[80a0b631737fb765]::util::run_in_thread_with_globals<rustc_interface[80a0b631737fb765]::interface::run_compiler<core[7fef78d3beba6ff5]::result::Result<(), rustc_span[865b327b21456c24]::ErrorGuaranteed>, rustc_driver_impl[7bf504f3f6583165]::run_compiler::{closure#0}>::{closure#0}, core[7fef78d3beba6ff5]::result::Result<(), rustc_span[865b327b21456c24]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7fef78d3beba6ff5]::result::Result<(), rustc_span[865b327b21456c24]::ErrorGuaranteed>>
  23:     0x7df335133c4f - <<std[85008a29cc0b7dba]::thread::Builder>::spawn_unchecked_<rustc_interface[80a0b631737fb765]::util::run_in_thread_with_globals<rustc_interface[80a0b631737fb765]::interface::run_compiler<core[7fef78d3beba6ff5]::result::Result<(), rustc_span[865b327b21456c24]::ErrorGuaranteed>, rustc_driver_impl[7bf504f3f6583165]::run_compiler::{closure#0}>::{closure#0}, core[7fef78d3beba6ff5]::result::Result<(), rustc_span[865b327b21456c24]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[7fef78d3beba6ff5]::result::Result<(), rustc_span[865b327b21456c24]::ErrorGuaranteed>>::{closure#1} as core[7fef78d3beba6ff5]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  24:     0x7df3360cc675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h6b630278c760b971
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/alloc/src/boxed.rs:2015:9
  25:     0x7df3360cc675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h70462b441b6c0e1f
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/alloc/src/boxed.rs:2015:9
  26:     0x7df3360cc675 - std::sys::pal::unix::thread::Thread::new::thread_start::h3631815ad38387d6
                               at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys/pal/unix/thread.rs:108:17
  27:     0x7df3302a955a - <unknown>
  28:     0x7df330326a3c - <unknown>
  29:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.77.2 (25ef9e3d8 2024-04-09) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type lib -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
end of query stack
error: could not compile `lace-language-compiler` (lib)

I'm sorry I cannot give you more to go on except the target folder maybe? Let me know if that'd be useful to you. (zipped: 268M)

@jdonszelmann jdonszelmann 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 Apr 19, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 19, 2024
@saethlin saethlin self-assigned this Apr 20, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Apr 20, 2024
@saethlin
Copy link
Member

This is the truncated dep graph crash that I've been hunting. We get this particular ICE because the last few bytes of a dep graph file are supposed to be the length of a Vec and so if the file is truncated arbitrary bytes get reinterpreted as a length and when multiplied by the size of the element type, we get overflow.

I'm assigning myself to keep track of such issues.

What filesystem are you using?

@saethlin saethlin added the A-incr-comp Area: Incremental compilation label Apr 20, 2024
@jdonszelmann
Copy link
Contributor Author

Btrfs

@bjorn3
Copy link
Member

bjorn3 commented Apr 21, 2024

@saethlin Maybe add a magic value at the end of the dep graph file and if that value is not present when decoding consider the incr comp session corrupt and ignore it? If the magic value is 16 random bytes, it is very unlikely that they will occur anywhere other than at the end, as such it would catch a truncated file with extremely high certainty.

@saethlin
Copy link
Member

Yes that was suggested to me before.

@saethlin
Copy link
Member

Such a check can detect this scenario but it cannot distinguish been a bug in the compiler and a problem with the environment. The fact that we weren't papering over such invalid files is what allowed me to fix multiple bugs that were in the compiler for over a year and were reported numerous times.

I am not interested in just detecting invalid files and papering over the situation.

@coolreader18
Copy link
Contributor

coolreader18 commented Apr 25, 2024

Got a similar ICE - my computer frozen while cargo was building the project and upon rebooting and retrying got this.

stacktrace
thread 'rustc' panicked at library/alloc/src/raw_vec.rs:570:5:
capacity overflow
stack backtrace:
   0:     0x74fcea3d7d16 - std::backtrace_rs::backtrace::libunwind::trace::h92ba5ac126ecc5ad
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:     0x74fcea3d7d16 - std::backtrace_rs::backtrace::trace_unsynchronized::hfaa118b6e3a8f31a
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x74fcea3d7d16 - std::sys_common::backtrace::_print_fmt::h2075f185adf13bbd
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:68:5
   3:     0x74fcea3d7d16 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h9c4bd387f9f3f544
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x74fcea42a770 - core::fmt::rt::Argument::fmt::h018ecebdf268b5bb
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/fmt/rt.rs:142:9
   5:     0x74fcea42a770 - core::fmt::write::h938c332fdab924eb
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/fmt/mod.rs:1120:17
   6:     0x74fcea3cb58f - std::io::Write::write_fmt::h4a694b02e44e6363
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/io/mod.rs:1846:15
   7:     0x74fcea3d7af4 - std::sys_common::backtrace::_print::h3595c0f4303f3ccd
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:47:5
   8:     0x74fcea3d7af4 - std::sys_common::backtrace::print::ha888e6736b0bc71f
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:34:9
   9:     0x74fcea3da887 - std::panicking::default_hook::{{closure}}::he19a7f79f7beab5e
  10:     0x74fcea3da5e9 - std::panicking::default_hook::h67efe04e9a5d446e
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:292:9
  11:     0x74fce71af6bc - std[c78d3cd131ec7074]::panicking::update_hook::<alloc[4e128ca7a2328977]::boxed::Box<rustc_driver_impl[f73d4ac0dd51449f]::install_ice_hook::{closure#0}>>::{closure#0}
  12:     0x74fcea3dafd6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h9c9759b104a0af15
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/alloc/src/boxed.rs:2029:9
  13:     0x74fcea3dafd6 - std::panicking::rust_panic_with_hook::h49021cdbc4b22349
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:785:13
  14:     0x74fcea3dace9 - std::panicking::begin_panic_handler::{{closure}}::hfbf601f3d8c62d13
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:651:13
  15:     0x74fcea3d8216 - std::sys_common::backtrace::__rust_end_short_backtrace::h98dd020b6e913806
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys_common/backtrace.rs:171:18
  16:     0x74fcea3daa74 - rust_begin_unwind
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/panicking.rs:647:5
  17:     0x74fcea426e75 - core::panicking::panic_fmt::h0d3f1893e38be419
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/core/src/panicking.rs:72:14
  18:     0x74fcea417daf - alloc::raw_vec::capacity_overflow::hdebe4d61eabe5c80
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/alloc/src/raw_vec.rs:570:5
  19:     0x74fce93f9917 - rustc_incremental[b64084db19a0a9a5]::persist::load::setup_dep_graph
  20:     0x74fce93461ae - <rustc_interface[aa0080c74e239226]::queries::Queries>::global_ctxt
  21:     0x74fce90ea5ae - rustc_interface[aa0080c74e239226]::interface::run_compiler::<core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>, rustc_driver_impl[f73d4ac0dd51449f]::run_compiler::{closure#0}>::{closure#0}
  22:     0x74fce93382f1 - std[c78d3cd131ec7074]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[aa0080c74e239226]::util::run_in_thread_with_globals<rustc_interface[aa0080c74e239226]::interface::run_compiler<core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>, rustc_driver_impl[f73d4ac0dd51449f]::run_compiler::{closure#0}>::{closure#0}, core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>>
  23:     0x74fce933814f - <<std[c78d3cd131ec7074]::thread::Builder>::spawn_unchecked_<rustc_interface[aa0080c74e239226]::util::run_in_thread_with_globals<rustc_interface[aa0080c74e239226]::interface::run_compiler<core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>, rustc_driver_impl[f73d4ac0dd51449f]::run_compiler::{closure#0}>::{closure#0}, core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[853b3d1bf84aeb53]::result::Result<(), rustc_span[9a816cd1dc398d83]::ErrorGuaranteed>>::{closure#1} as core[853b3d1bf84aeb53]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
  24:     0x74fcea3e4675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h4f08d401a486e446
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/alloc/src/boxed.rs:2015:9
  25:     0x74fcea3e4675 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h3476dfcdba628abc
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/alloc/src/boxed.rs:2015:9
  26:     0x74fcea3e4675 - std::sys::pal::unix::thread::Thread::new::thread_start::h2770ac7f8882db09
                               at /rustc/aedd173a2c086e558c2b66d3743b344f977621a7/library/std/src/sys/pal/unix/thread.rs:108:17
  27:     0x74fce44a955a - <unknown>
  28:     0x74fce4526a5c - <unknown>
  29:                0x0 - <unknown>

error: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.77.0 (aedd173a2 2024-03-17) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C codegen-units=256 -C debuginfo=2 -C incremental=[REDACTED]

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

query stack during panic:
end of query stack

@saethlin
Copy link
Member

As far as I can tell, the ICE reported in this issue is caused by another process damaging rustc's build artifacts or by a buggy filesystem. That other process could be anything from an IDE running the compiler at the same time as a manual build to a find-and-replace that accidentally edits files in the target directory.

#124686 contains a mitigation for this situation; the compiler now has a crude way to detect and ignore damaged incremental compilation files. You will still get a warning about the damaged file, but the build should proceed normally. That change shipped in Rust 1.80 which released today, so I am closing this issue and a few others which as far as I can tell all have the same root cause. You shouldn't see this ICE anymore, but please file a new issue if you see something like it on 1.80 or later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-incr-comp Area: Incremental compilation 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.
Projects
None yet
Development

No branches or pull requests

5 participants