Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-08-02
08:14 • Closed ticket [6e82720e14]: Panic "Buffer Underflow, BUFFER_PADDING not eno... artifact: 19241f1e55 user: apnadkarni
08:11
Fix [6e82720e] - BUFFER_PADDING panic on 4294967296 chars read check-in: 5a2face991 user: apnadkarni tags: trunk, main
05:48 • Ticket [6e82720e14] Panic "Buffer Underflow, BUFFER_PADDING not enough&quot... artifact: 02e6fe2dab user: apnadkarni
2026-07-29
06:43
Proposed fix for [6e82720e14]. check-in: d90ac91a23 user: apnadkarni tags: bug-6e82720e
05:55 • Ticket [6e82720e14] Panic "Buffer Underflow, BUFFER_PADDING not enough&quot... artifact: 585ea97fc3 user: apnadkarni
05:55 • Ticket [6e82720e14]: 3 changes artifact: 744a975337 user: apnadkarni
05:40
Add tests to recreate [6e82720e] without creating large files on disk check-in: 9923435ca6 user: apnadkarni tags: bug-6e82720e
2026-07-28
12:03 • Ticket [6e82720e14] Panic "Buffer Underflow, BUFFER_PADDING not enough&quot... artifact: 89ed737f77 user: tomkiti
11:56 • New ticket [6e82720e14]. artifact: b11df8219f user: tomkiti

Panic "Buffer Underflow, BUFFER_PADDING not enough" when reading files >= 4 GB

Closed / Fixed6e82720e146403fadc88117c0e4fe1a7deff0fe6Created 127 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
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.