include_str fails with large files #52380
Labels
C-bug
Category: This is a bug.
I-compilemem
Issue: Problems and improvements with respect to memory usage during compilation.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I just tried to
include_str!()
a 14g file.It failed with:
failure with 16g file
Same error with everything down to five gigabytes (which would fit in my ram thrice).
Then I thought, hey, 32-bit and ran the following:
failure with 2^32+1 file
failure with 2^32 file
failure with 2^32-1 file
failure with 2^32-1 file & RUST_BACKTRACE
Content of the file was generated by
base64 /dev/urandom | pv -Ss 16g > file
(and subsequentlytruncate
d).A file created using
truncate
yields only the error of ≥2³² as described above though, so the error might have to do withinclude_str!
.This is happening on:
tested rustc stable
tested rustc nightly
Used code:
Nightly yields a litte more info:
nightly with backtrace and empty (truncated) file
Edit: seems as if the problem is happening due to running out of RAM because of doubling allocation sizes. Reported
memory allocation of ${n} bytes failed
messages on nightly are always powers of two and htop shows those allocations adding up pretty well. However this also happens with a 1g file. Running out of 16g of RAM wheninclude_str!()
ing a 1g file shouldn't happen, yet I can't tell where the problematic allocation(s) happen(s).The text was updated successfully, but these errors were encountered: