Skip to content

ICE when compiling a source file with size 4 GiB - 1 B #132862

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

Closed
tyilo opened this issue Nov 10, 2024 · 1 comment
Closed

ICE when compiling a source file with size 4 GiB - 1 B #132862

tyilo opened this issue Nov 10, 2024 · 1 comment
Labels
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

@tyilo
Copy link
Contributor

tyilo commented Nov 10, 2024

Compiling a source file with size 4 GiB - 1 B (u32::MAX bytes) makes the compiler crash.

Compiling a source file of size 4 GiB produces the correct error fatal error: rustc does not support files larger than 4GB, whereas compiling a source file of size 4 GiB - 2 B works.

Code

Code generated by python:

python -c 'print("fn main(){println!(\"hello world\");}/*" + "a"*(4 * 1024**3 - 41) + "*/")' > main.rs
fn main(){println!("hello world");}/*aaa...aaa*/

Meta

Happens in both latest stable and nightly:

rustc +stable --version --verbose:

rustc 1.82.0 (f6e511eec 2024-10-15)
binary: rustc
commit-hash: f6e511eec7342f59a25f7c0534f1dbea00d01b14
commit-date: 2024-10-15
host: x86_64-unknown-linux-gnu
release: 1.82.0
LLVM version: 19.1.1

rustc +nightly --version --verbose:

rustc 1.84.0-nightly (59cec72a5 2024-11-08)
binary: rustc
commit-hash: 59cec72a57af178767a7b8e7f624b06cc50f1087
commit-date: 2024-11-08
host: x86_64-unknown-linux-gnu
release: 1.84.0-nightly
LLVM version: 19.1.3

Error output

thread 'rustc' panicked at compiler/rustc_span/src/source_map.rs:369:14:
not enough address space for imported source file: OffsetOverflowError
stack backtrace:
  ...
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

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: please make sure that you have updated to the latest nightly

note: please attach the file at `/var/tmp/rustc-ice-2024-11-10T16_10_48-1065892.txt` to your bug report

query stack during panic:
#0 [resolver_for_lowering_raw] getting the resolver for lowering
end of query stack
Backtrace

   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: <rustc_metadata::rmeta::decoder::DecodeContext as rustc_span::SpanDecoder>::decode_span
   4: <rustc_metadata::creader::CStore>::def_span_untracked
   5: <rustc_resolve::Resolver>::get_module
   6: <rustc_resolve::build_reduced_graph::BuildReducedGraphVisitor as rustc_ast::visit::Visitor>::visit_item
   7: <rustc_resolve::Resolver as rustc_expand::base::ResolverExpand>::visit_ast_fragment_with_placeholders
   8: <rustc_expand::expand::MacroExpander>::collect_invocations
   9: <rustc_expand::expand::MacroExpander>::fully_expand_fragment
  10: <rustc_expand::expand::MacroExpander>::expand_crate
  11: rustc_interface::passes::resolver_for_lowering_raw
      [... omitted 2 frames ...]
  12: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}

rustc-ice-2024-11-10T16_10_48-1065892.txt

@tyilo tyilo 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 Nov 10, 2024
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 10, 2024
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Nov 10, 2024
@clubby789
Copy link
Contributor

file.start_pos = BytePos(if let Some(last_file) = files.source_files.last() {
// Add one so there is some space between files. This lets us distinguish
// positions in the `SourceMap`, even in the presence of zero-length files.
last_file.end_position().0.checked_add(1).ok_or(OffsetOverflowError)?

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. 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

4 participants