Panic "Buffer Underflow, BUFFER_PADDING not enough" when reading files >= 4 GB
Closed / Fixed6e82720e146403fadc88117c0e4fe1a7deff0fe6Created 128 days agoUpdated 123 days ago
Descriptionmarkdown2026-07-28 11:56:50
When reading files >= 4 GB, Tcl 9 panics with the error "Buffer Underflow, BUFFER_PADDING not enough".
I created a 4 GB file on Windows with the command:
fsutil file createnew 4294967296.txt 4294967296
The following script crashes on Windows and Linux:
set filename 4294967296.txt
set chan [open $filename r]
read $chan [file size $filename]
close $chan
A filesize of 4294967295 works.
Tcl 8 throws the following error:
expected non-negative integer but got "4294967296"
while executing
"read $chan [file size $filename]"
Referenced by1
d90ac91a23Proposed fix for [6e82720e14]. check-in2026-07-29 06:43:14
tomkiti Ticket [6e82720e14]: 4 changes
[History diff]2026-07-28 12:03:20
apnadkarnimarkdown2026-07-29 05:55:13
Does not even need a large file on disk. Appears to be reproducible with 4294967296 size reads on any size file.
WIP on branch bug-6e82720e
apnadkarni Ticket [6e82720e14]: 3 changes
[History diff]2026-07-29 05:55:28
apnadkarnimarkdown2026-08-02 05:48:55
A related failure mode also shows up in 8.6
% file size x.txt
2
% set fd [open x.txt]
file1dd2964bc10
% read $fd 4294967296
% <- empty result. Should return the file content
apnadkarniplain2026-08-02 08:14:10
Fixed for 9.1 in [5a2face9]. No plans to fix for 9.0 as it is dependent on TIP 737 which targets 9.1. A 9.0 fix would require additional changes and not seen as worthwhile for a rare/corner case. Closing accordingly.
Log in (anonymous is fine) to add a comment.