-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
Description
There is currently a discrepancy between uutils/wc and GNU coreutils/wc regarding large files.
When processing multiple extremely large (possibly sparse) files, the cumulative total can exceed the capacity of a 64-bit integer. Currently, uutils/wc panics in debug builds or wraps around in release builds, whereas GNU wc handles this gracefully by saturating at the maximum value and issuing a diagnostic error.
Steps to Reproduce
Using sparse files to simulate sizes exceeding
2**64−1
# Create a 2-exabyte sparse file
truncate -s 2E big
# Trigger overflow by summing multiple instances
uutils-wc -c big big big big big big big big big big
Current Behavior: Panic or silent wrap-around.
GNU Behavior: Prints a diagnostic wc: count overflow to stderr, saturates the count at u64::MAX, and exits with status 1.
I'd like to handle the problem. I would replace usize with u64 for the counters and check for overflow.
Reactions are currently unavailable