Skip to content

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

Closed
@tyilo

Description

@tyilo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions