You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG]: read_bytes() function reads a maximum file size of 2GB when the size argument is specified #1622
bugSomething isn't workingmojoIssues that are related to mojomojo-repoTag all issues with this labelmojo-stdlibTag for issues related to standard library
As per the title.
When the read_bytes() function is invoked on a FileHandle, it can read the whole file until EOF. However, when the size is specified, the maximum size that can be read is 1.99GB (2,147,479,552 bytes; closer to the max size representation of Int32), although the size argument itself should have a Int64 type.
Steps to reproduce
fn main() raises:
let path ="/path/to/huge/file.(tar.gz, fastq)"
let handle = open(path, "r")
let chunk = handle.read_bytes(SIMD[DType.int64, 1](8*1024*1024*1024))
print(chunk)
Tensor([[31, -117, 8, ..., -40, 125, 127]], dtype=int8, shape=2147479552)
I tried with a few filetypes (archives and plain text files) and the resut is the same
System information
- What OS did you do install Mojo on ? WSL2, also replicable on Ubuntu 22.04
- Provide version information for Mojo by pasting the output of `mojo -v`: mojo 0.6.1 (876ded2e)
- Provide Modular CLI version by pasting the output of `modular -v`: modular 0.2.0 (355ea9c0)
Thanks for reporting, @MoSafi2! read_bytes now keeps reading until it has the requested size, and @Alex-Wengg fixed the remaining macOS failure for reads over 2 GiB in #7617; on a current build of main, read_bytes(2_300_000_000) returns all 2.3 GB. The fix is in nightly builds and will ship in the next stable release, so I'm closing this.
bugSomething isn't workingmojoIssues that are related to mojomojo-repoTag all issues with this labelmojo-stdlibTag for issues related to standard library
Activity
NathanSWard commentedon Dec 1, 2026
Thanks for reporting, @MoSafi2!
read_bytesnow keeps reading until it has the requested size, and @Alex-Wengg fixed the remaining macOS failure for reads over 2 GiB in #7617; on a current build of main,read_bytes(2_300_000_000)returns all 2.3 GB. The fix is in nightly builds and will ship in the next stable release, so I'm closing this.