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
Integer overflow with huge files #58
Comments
You have just shattered my idea that nobody, ever, would hit the limits of u64, who can fit the amount of stars in the known universe multiple times and all :D. Probably that idea of mines is quite similar to that other one, along the lines of "640kb of main memory is going to be enough" :D. Out of curousity: How did you produce these files? Are they actually backed by that much disk space? To the point: I think it would not be an issue to represent the final aggregation as u128. |
❯ truncate -s 9223372036854775807 huge1
❯ l huge1
.rw-r--r-- 9.2E freaky freaky 1 Jul 15:56 huge1 They're sparse files and consume no more space than an empty file. I'll have a look and see if I get bored before I finish fixing the compiler errors ;) |
Per issue Byron#58, u64 is insufficient for use with very large sparse files. Enormous file sizes are also a common filesystem error trope, either from disk corruption or software bugs, and they're also conceivable with virtual filesystems. Handle this as gracefully as can be reasonably expected using 128-bit integers, which should be sufficient for most uses.
Test environment: ❯ truncate -s 9223372036854775807 huge/{1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9} Before: ❯ dua -A huge
18.45 EB huge After: ❯ dua -A huge
8.30 ZB huge |
Per issue #58, u64 is insufficient for use with very large sparse files. Enormous file sizes are also a common filesystem error trope, either from disk corruption or software bugs, and they're also conceivable with virtual filesystems. Handle this as gracefully as can be reasonably expected using 128-bit integers, which should be sufficient for most uses.
Wonderful! I wasn't aware that Closing this issue as the PR fixing it was merged. |
When faced with file sizes that sum beyond the limits of a u64, such as:
dua -A
in debug mode panics:And produces incorrect results in release builds:
Not really worse than most other similar tools - GNU
du
just gives up and declares the size infinite, and BSDdu
seems to believe negative file sizes are possible - but perhaps it would be nice to Just Work, given Rust's u128 support.The text was updated successfully, but these errors were encountered: