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

rustc panics due to stale incremental compilation info #120582

Closed
stinodego opened this issue Jan 17, 2024 · 14 comments
Closed

rustc panics due to stale incremental compilation info #120582

stinodego opened this issue Jan 17, 2024 · 14 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) ❄️

Comments

@stinodego
Copy link

stinodego commented Jan 17, 2024

Summary

Unfortunately I cannot reproduce this after running cargo clean.

I was implementing the Not trait rather than implementing .not() directly and at some point I got this panick when running clippy. cargo build still worked fine.

Here's the branch I was working on:
https://github.com/pola-rs/polars/tree/72aa9515f385f1a2d30802a50ef851fcf92c2e6a

I hope this may still be useful somehow.

Version

rustc 1.77.0-nightly (d6d7a9386 2023-12-22)
binary: rustc
commit-hash: d6d7a93866f2ffcfb51828b8859bdad760b54ce0
commit-date: 2023-12-22
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6

Error output

Backtrace

cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
  Checking polars-ops v0.36.2 (/home/stijn/code/polars/crates/polars-ops)
thread 'rustc' panicked at library/alloc/src/raw_vec.rs:571:5:
capacity overflow
stack backtrace:
thread 'rustc' panicked at library/alloc/src/raw_vec.rs:571:5:
capacity overflow
stack backtrace:
 0:     0x7ff54598b6f6 - std::backtrace_rs::backtrace::libunwind::trace::h4c39d39dfbe9783d
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
 1:     0x7ff54598b6f6 - std::backtrace_rs::backtrace::trace_unsynchronized::h4dc8ace54ae311e5
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
 2:     0x7ff54598b6f6 - std::sys_common::backtrace::_print_fmt::hb93bb30078f88f5e
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/sys_common/backtrace.rs:68:5
 3:     0x7ff54598b6f6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc0a088b7e0825f6a
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/sys_common/backtrace.rs:44:22
 4:     0x7ff5459ddf40 - core::fmt::rt::Argument::fmt::h3bf37701eb7e7bdb
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/core/src/fmt/rt.rs:142:9
 5:     0x7ff5459ddf40 - core::fmt::write::h7e6ab5f6daf5c422
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/core/src/fmt/mod.rs:1120:17
 6:     0x7ff54597f4af - std::io::Write::write_fmt::h08c3306cb5bf723d
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/io/mod.rs:1810:15
 7:     0x7ff54598b4d4 - std::sys_common::backtrace::_print::hafed43d2fa285a46
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/sys_common/backtrace.rs:47:5
 8:     0x7ff54598b4d4 - std::sys_common::backtrace::print::h39c23a58558ca2e2
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/sys_common/backtrace.rs:34:9
 9:     0x7ff54598e267 - std::panicking::default_hook::{{closure}}::h33423deafbc8e615
10:     0x7ff54598dfc9 - std::panicking::default_hook::h50ae27bf0009ee3b
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/panicking.rs:292:9
 0:     0x7f0df2d8b6f6 - std::backtrace_rs::backtrace::libunwind::trace::h4c39d39dfbe9783d
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
 1:     0x7f0df2d8b6f6 - std::backtrace_rs::backtrace::trace_unsynchronized::h4dc8ace54ae311e5
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
 2:     0x7f0df2d8b6f6 - std::sys_common::backtrace::_print_fmt::hb93bb30078f88f5e
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/sys_common/backtrace.rs:68:5
 3:     0x7f0df2d8b6f6 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc0a088b7e0825f6a
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/sys_common/backtrace.rs:44:22
 4:     0x7f0df2dddf40 - core::fmt::rt::Argument::fmt::h3bf37701eb7e7bdb
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/core/src/fmt/rt.rs:142:9
 5:     0x7f0df2dddf40 - core::fmt::write::h7e6ab5f6daf5c422
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/core/src/fmt/mod.rs:1120:17
 6:     0x7f0df2d7f4af - std::io::Write::write_fmt::h08c3306cb5bf723d
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/io/mod.rs:1810:15
 7:     0x7f0df2d8b4d4 - std::sys_common::backtrace::_print::hafed43d2fa285a46
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/sys_common/backtrace.rs:47:5
 8:     0x7f0df2d8b4d4 - std::sys_common::backtrace::print::h39c23a58558ca2e2
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/sys_common/backtrace.rs:34:9
 9:     0x7f0df2d8e267 - std::panicking::default_hook::{{closure}}::h33423deafbc8e615
10:     0x7f0df2d8dfc9 - std::panicking::default_hook::h50ae27bf0009ee3b
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/panicking.rs:292:9
11:     0x7ff548782ccc - std[3a009c5aa3cd6e18]::panicking::update_hook::<alloc[7046a3554d0212f6]::boxed::Box<rustc_driver_impl[99e8362fbaa298ef]::install_ice_hook::{closure#0}>>::{closure#0}
12:     0x7ff54598e9b6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h5ddf83902817cab1
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/alloc/src/boxed.rs:2029:9
13:     0x7ff54598e9b6 - std::panicking::rust_panic_with_hook::hbc586ac9df6b73a8
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/panicking.rs:783:13
14:     0x7ff54598e6c9 - std::panicking::begin_panic_handler::{{closure}}::hf311b40154e75f12
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/panicking.rs:649:13
15:     0x7ff54598bbf6 - std::sys_common::backtrace::__rust_end_short_backtrace::he9e1eb231bad02f7
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/sys_common/backtrace.rs:171:18
16:     0x7ff54598e460 - rust_begin_unwind
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/panicking.rs:645:5
17:     0x7ff5459da645 - core::panicking::panic_fmt::hefa1490703b8b929
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/core/src/panicking.rs:72:14
18:     0x7ff5459cb98f - alloc::raw_vec::capacity_overflow::h0a679f9c4fe31dca
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/alloc/src/raw_vec.rs:571:5
19:     0x7ff54aac931c - rustc_incremental[c3ec564ce92581fa]::persist::load::setup_dep_graph
20:     0x7ff54a836598 - <rustc_interface[dfee6d40a3df20bb]::queries::Queries>::global_ctxt
21:     0x7ff54a99f082 - rustc_interface[dfee6d40a3df20bb]::interface::run_compiler::<core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>, rustc_driver_impl[99e8362fbaa298ef]::run_compiler::{closure#0}>::{closure#0}
22:     0x7ff54a925346 - std[3a009c5aa3cd6e18]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[dfee6d40a3df20bb]::util::run_in_thread_with_globals<rustc_interface[dfee6d40a3df20bb]::util::run_in_thread_pool_with_globals<rustc_interface[dfee6d40a3df20bb]::interface::run_compiler<core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>, rustc_driver_impl[99e8362fbaa298ef]::run_compiler::{closure#0}>::{closure#0}, core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>>::{closure#0}, core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>>
23:     0x7ff54a925173 - <<std[3a009c5aa3cd6e18]::thread::Builder>::spawn_unchecked_<rustc_interface[dfee6d40a3df20bb]::util::run_in_thread_with_globals<rustc_interface[dfee6d40a3df20bb]::util::run_in_thread_pool_with_globals<rustc_interface[dfee6d40a3df20bb]::interface::run_compiler<core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>, rustc_driver_impl[99e8362fbaa298ef]::run_compiler::{closure#0}>::{closure#0}, core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>>::{closure#0}, core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>>::{closure#1} as core[2b984803ee3f5e21]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
24:     0x7ff5459988e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h446fa4c55b1bf8c4
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/alloc/src/boxed.rs:2015:9
25:     0x7ff5459988e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb661ed53115c5033
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/alloc/src/boxed.rs:2015:9
26:     0x7ff5459988e5 - std::sys::unix::thread::Thread::new::thread_start::hbd74c47d36330101
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/sys/unix/thread.rs:108:17
27:     0x7ff54565fac3 - <unknown>
28:     0x7ff5456f1a40 - <unknown>
29:                0x0 - <unknown>

11:     0x7f0df5b82ccc - std[3a009c5aa3cd6e18]::panicking::update_hook::<alloc[7046a3554d0212f6]::boxed::Box<rustc_driver_impl[99e8362fbaa298ef]::install_ice_hook::{closure#0}>>::{closure#0}
12:     0x7f0df2d8e9b6 - <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call::h5ddf83902817cab1
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/alloc/src/boxed.rs:2029:9
13:     0x7f0df2d8e9b6 - std::panicking::rust_panic_with_hook::hbc586ac9df6b73a8
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/panicking.rs:783:13
14:     0x7f0df2d8e6c9 - std::panicking::begin_panic_handler::{{closure}}::hf311b40154e75f12
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/panicking.rs:649:13
15:     0x7f0df2d8bbf6 - std::sys_common::backtrace::__rust_end_short_backtrace::he9e1eb231bad02f7
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/sys_common/backtrace.rs:171:18
16:     0x7f0df2d8e460 - rust_begin_unwind
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/panicking.rs:645:5
17:     0x7f0df2dda645 - core::panicking::panic_fmt::hefa1490703b8b929
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/core/src/panicking.rs:72:14
18:     0x7f0df2dcb98f - alloc::raw_vec::capacity_overflow::h0a679f9c4fe31dca
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/alloc/src/raw_vec.rs:571:5
19:     0x7f0df7ec931c - rustc_incremental[c3ec564ce92581fa]::persist::load::setup_dep_graph
20:     0x7f0df7c36598 - <rustc_interface[dfee6d40a3df20bb]::queries::Queries>::global_ctxt
21:     0x7f0df7d9f082 - rustc_interface[dfee6d40a3df20bb]::interface::run_compiler::<core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>, rustc_driver_impl[99e8362fbaa298ef]::run_compiler::{closure#0}>::{closure#0}
22:     0x7f0df7d25346 - std[3a009c5aa3cd6e18]::sys_common::backtrace::__rust_begin_short_backtrace::<rustc_interface[dfee6d40a3df20bb]::util::run_in_thread_with_globals<rustc_interface[dfee6d40a3df20bb]::util::run_in_thread_pool_with_globals<rustc_interface[dfee6d40a3df20bb]::interface::run_compiler<core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>, rustc_driver_impl[99e8362fbaa298ef]::run_compiler::{closure#0}>::{closure#0}, core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>>::{closure#0}, core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>>
23:     0x7f0df7d25173 - <<std[3a009c5aa3cd6e18]::thread::Builder>::spawn_unchecked_<rustc_interface[dfee6d40a3df20bb]::util::run_in_thread_with_globals<rustc_interface[dfee6d40a3df20bb]::util::run_in_thread_pool_with_globals<rustc_interface[dfee6d40a3df20bb]::interface::run_compiler<core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>, rustc_driver_impl[99e8362fbaa298ef]::run_compiler::{closure#0}>::{closure#0}, core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>>::{closure#0}, core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>>::{closure#0}::{closure#0}, core[2b984803ee3f5e21]::result::Result<(), rustc_span[fa12e73b1270738]::ErrorGuaranteed>>::{closure#1} as core[2b984803ee3f5e21]::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
24:     0x7f0df2d988e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h446fa4c55b1bf8c4
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/alloc/src/boxed.rs:2015:9
25:     0x7f0df2d988e5 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::hb661ed53115c5033
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/alloc/src/boxed.rs:2015:9
26:     0x7f0df2d988e5 - std::sys::unix::thread::Thread::new::thread_start::hbd74c47d36330101
                             at /rustc/d6d7a93866f2ffcfb51828b8859bdad760b54ce0/library/std/src/sys/unix/thread.rs:108:17
27:     0x7f0df2a5fac3 - <unknown>
28:     0x7f0df2af1a40 - <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-clippy/issues/new?template=ice.yml

note: please attach the file at `/home/stijn/code/polars/rustc-ice-2024-01-17T09_42_36-19672.txt` to your bug report

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
note: Clippy version: clippy 0.1.76 (d6d7a93 2023-12-22)

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

note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml

note: please attach the file at `/home/stijn/code/polars/rustc-ice-2024-01-17T09_42_36-19674.txt` to your bug report

note: compiler flags: -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
note: Clippy version: clippy 0.1.76 (d6d7a93 2023-12-22)

error: could not compile `polars-ops` (lib)
warning: build failed, waiting for other jobs to finish...
error: could not compile `polars-ops` (lib test)
make: *** [Makefile:81: clippy] Error 101

@stinodego stinodego added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 17, 2024
@stinodego stinodego changed the title Clippy panicks due to Neg trait implementation? Clippy panicks due to Not trait implementation? Jan 17, 2024
@m-rph
Copy link
Contributor

m-rph commented Feb 1, 2024

Hi thanks for the report!

At a first glance this doesn't seem like a clippy issue but a compiler internals issue.
I will take a look, if it is, I will open an issue in rustc, otherwise will submit a PR.

@rustbot claim

@flip1995
Copy link
Member

flip1995 commented Feb 1, 2024

Unfortunately I cannot reproduce this after running cargo clean.

Maybe some stale incremental compilation state, that caused rustc to panic? This indeed doesn't sound like a Clippy issue. Curious what you come up with and how to reproduce this.

@m-rph
Copy link
Contributor

m-rph commented Feb 1, 2024

I pulled that specific commit, and couldn't reproduce with the nightly-2024-01-11 toolchain.

It seems that the issue may have happened during compilation as @flip1995 suggested, and not during clippy run.

I run this in the repo dir:

cargo +nightly-2024-01-11 clippy

image

I will try going through the commit history.

@stinodego
Copy link
Author

Maybe some stale incremental compilation state, that caused rustc to panic?

That's what I am thinking. At some point I ran into the panic, then I was reverting changes but it kept happening, and then after running cargo clean the panic went away. And I could re-apply my changes without running into the panic again.

Unfortunately that made it impossible for me to reliably reproduce, given my limited knowledge of this subject.

@m-rph
Copy link
Contributor

m-rph commented Feb 1, 2024

What I am thinking is that somehow cargo build had access to previous files that resulted in a successful compilation, and running clippy caused a rebuild with a stale state.

From the stacktrace it appears that the issue is related to the query engine ie type checking, and the compilation error I am getting is related to that as well 🤔.

It looks unlikely, but if you run something like bacon it's more probable.

Accessing deleted files by having references to them is a thing that can occur in linux systems.

This example comes to mind https://lkml.iu.edu/hypermail/linux/kernel/2401.3/05626.html

@flip1995
Copy link
Member

flip1995 commented Feb 2, 2024

Should we close this issue or move it to rustc? As there doesn't seem to be a reproducer, it's almost impossible to fix this.

@m-rph
Copy link
Contributor

m-rph commented Feb 2, 2024

I think it's best to simply report to rustc.

Til you can move issues around.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 2, 2024
@flip1995 flip1995 transferred this issue from rust-lang/rust-clippy Feb 2, 2024
@flip1995 flip1995 changed the title Clippy panicks due to Not trait implementation? rustc panics due to stale incremental compilation info Feb 2, 2024
@flip1995 flip1995 added the A-incr-comp Area: Incremental compilation label Feb 5, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 12, 2024
@saethlin
Copy link
Member

@partiallytyped Do you still want to be assigned to this issue?

@m-rph
Copy link
Contributor

m-rph commented Feb 12, 2024

@saethlin This is unfortunately beyond my skills at the moment. Please take it away if you want.

@saethlin saethlin assigned saethlin and unassigned m-rph Feb 12, 2024
@saethlin
Copy link
Member

The crash here is happening when loading the incremental compilation dependency graph. I've worked on that code a fair bit.

What jumps out at me is that we blindly assume that the last 16 bytes are the number of edges and number of nodes. Usually when decoders crash with a capacity overflow or allocation error it's because they're trying to pre-allocate for an array, and the decoder read some random bytes instead of a length. The encoding format tries to adapt itself to minimize the number of zero bytes it writes, so the odds are actually quite good that if you grab a random 8 bytes of the dep graph file and then try to convert it from an element count to a number of bytes for an array's whole allocation (as the code in RawVec that crashes does), that multiplication will overflow.

So, it seems likely to me that somehow your dep graph file was incomplete. I've been trying to fix a situation that looks a whole lot like this, where if you ran out of disk space during a compile, rustc would fail to report an error correctly and just tell Cargo it finished compilation. Then a new rustc process would start up and try to load a truncated file and crash.

I'm afraid this looks exactly like that. @stinodego is there any chance you ran out of disk space recently? From the rustc version you reported, it looks like you're on a nightly before #119510 landed.

If there's no way you ran out of disk space recently, I have a patch that would at least let us detect that there's a truncated file and crash more helpfully.

@stinodego
Copy link
Author

I guess it's possible - I run on WSL and the virtual disk space gets filled up sometimes.

@amyipdev
Copy link

amyipdev commented Mar 9, 2024

w/r/t the Serenity example - disk space isn't an issue in my case, I can go check rn but my disk should be like 90-95% unused

workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 12, 2024
…etrochenkov

Detect truncated DepGraph files

I suspect that the following issues are caused by truncated incr comp files:

* rust-lang#120582
* rust-lang#121499
* rust-lang#122210

We fail with an allocation failure or capacity overflow in this case because we assume that the ending bytes of an DepGraph file are the lengths of arrays. If the file has somehow been truncated then the ending bytes are probably some of our varint encoding, which tries to eliminate zero bytes, so interpreting a random 8 bytes as an array length has a very high chance of producing a byte capacity over `isize::MAX`.

Now theoretically since rust-lang#119510 merged I have fixed the out-of-disk issues and yet in rust-lang#120894 (comment) I still see some decoding failures that look like out-of-disk ICEs, for example https://crater-reports.s3.amazonaws.com/beta-1.77-1/beta-2024-02-10/gh/scottfones.aoc_2022/log.txt

So this PR should ensure that we get an ICE that clearly identifies if the file in question is truncated.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 12, 2024
Rollup merge of rust-lang#122245 - saethlin:check-dep-graph-size, r=petrochenkov

Detect truncated DepGraph files

I suspect that the following issues are caused by truncated incr comp files:

* rust-lang#120582
* rust-lang#121499
* rust-lang#122210

We fail with an allocation failure or capacity overflow in this case because we assume that the ending bytes of an DepGraph file are the lengths of arrays. If the file has somehow been truncated then the ending bytes are probably some of our varint encoding, which tries to eliminate zero bytes, so interpreting a random 8 bytes as an array length has a very high chance of producing a byte capacity over `isize::MAX`.

Now theoretically since rust-lang#119510 merged I have fixed the out-of-disk issues and yet in rust-lang#120894 (comment) I still see some decoding failures that look like out-of-disk ICEs, for example https://crater-reports.s3.amazonaws.com/beta-1.77-1/beta-2024-02-10/gh/scottfones.aoc_2022/log.txt

So this PR should ensure that we get an ICE that clearly identifies if the file in question is truncated.
@saethlin
Copy link
Member

I think the root cause of this issue was rustc incorrectly handling/reporting I/O errors. I've landed a number of PRs to address the problem; the most recent of those is #119510 which is now part of the latest stable toolchain, 1.77. Therefore, even though I have not reproduced exactly what you've reported here, I'm going to close this because I am reasonably confident that this bug is now fixed on stable.

Of course it is possible that I am wrong and the bug you've reported here is not fixed. If you happen to run into problems like this in 1.77 or later please do not hesitate to open a new issue.

@stinodego
Copy link
Author

All right, thanks a lot!

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) ❄️
Projects
None yet
Development

No branches or pull requests

6 participants