Skip to content
Tcl Source Code View Ticket
Login

View Ticket

8.7, 9.0: Bad input triggers DoReadChars Assertion

Closed / Duplicate1136e210b342c25ec019c9b326bb24103eaed75fCreated 5 years agoUpdated 42 days ago
Descriptionplain2022-02-06 17:35:38
The following script reproduces the problem:

set fd [open bad.txt wb+]
# Seems (almost?) any character will do it
puts -nonewline $fd "a"
close $fd

# Happens for any enconding out of
# cns11643 gb2312-raw gb12345 jis0208 jis0212 ksc5601
set fd [open bad.txt]
fconfigure $fd -encoding cns11643
set badtext [read $fd]
close $fd

Running this with either 9.0 (current trunk) or 8.7 (core-8-branch) results in (just with different line numbers):

tclIO.c:5982: DoReadChars: Assertion `!GotFlag(statePtr, CHANNEL_EOF) || GotFlag(statePtr, CHANNEL_STICKY_EOF) || Tcl_InputBuffered((Tcl_Channel)chanPtr) == 0' failed.

and of course abortion of the process
serhiy.storchakawiki2026-10-13 16:29:20

Fixed by [a02c5b9f8b] for [25cdcb7e8f], the same assertion with an incomplete UTF-8 sequence at the end of the file. With assertions enabled, the script aborts with its parent [af256f4469] and works with it, 9.0.0 and 9.1.

serhiy.storchaka Ticket [1136e210b3]: 3 changes [History diff]2026-10-22 17:19:25
Log in (anonymous is fine) to add a comment.