Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-06-29
23:42
Bug [5be203d6ca] - io-7.3 failure. check-in: 2906d33993 user: pooryorick tags: unchained
2023-07-05
10:20 • Closed ticket [5be203d6ca]: io-7.3 and chanio-7.3 fail in debug mode plus 5 ... artifact: 308a578dd6 user: apnadkarni
06:39 • Ticket [5be203d6ca]: 3 changes artifact: 7767d7f269 user: apnadkarni
06:28 • Ticket [5be203d6ca]: 4 changes artifact: e9fe3b6fa5 user: oehhar
06:18 • Ticket [5be203d6ca]: 3 changes artifact: 2377afb392 user: apnadkarni
05:52
Merge 8.7 - Bug [5be203d6ca] - io-7.3 failure check-in: 4b6fd44d84 user: apnadkarni tags: trunk, main
05:08
Bug [5be203d6ca] - io-7.3 failure check-in: 7a68ac2af7 user: apnadkarni tags: core-8-branch
03:23
Bug [5be203d6ca] - better fix and add test closed check-in: b88bf9d6bd user: apnadkarni tags: bug-5be203d6ca-apn
2023-07-04
09:52 • Ticket [5be203d6ca] io-7.3 and chanio-7.3 fail in debug mode status still Op... artifact: 5450ce057b user: apnadkarni
09:22 • Ticket [5be203d6ca]: 4 changes artifact: f250e81a56 user: jan.nijtmans
06:58 • Ticket [5be203d6ca]: 3 changes artifact: aa1d28ee04 user: apnadkarni
2023-07-03
14:16
Branch meant for bug-fixing [5be203d6ca]: io-7.3 and chanio-7.3 fail in debug mode closed check-in: d70f500674 user: jan.nijtmans tags: bug-5be203d6ca
14:11 • Ticket [5be203d6ca] io-7.3 and chanio-7.3 fail in debug mode status still Op... artifact: 244f538fe4 user: jan.nijtmans
13:46
Temporary disable tests io-7.3 and chanio-7.3, which fail in debug mode. Ticket [5be203d6ca] created... check-in: 6b6caba07a user: jan.nijtmans tags: core-8-branch
13:44 • New ticket [5be203d6ca] io-7.3 and chanio-7.3 fail in debug mode. artifact: c1194e009d user: jan.nijtmans

io-7.3 and chanio-7.3 fail in debug mode

Closed / Fixed5be203d6caa9298363310b3436cb00e2928279c1Created 3 years agoUpdated 3 years ago
Descriptionwiki2023-07-03 13:44:15
Starting with [this] commit, in debug mode:
==== io-7.3 FilterInputBytes: split up character at EOF FAILED
==== Contents of test case:

set f [open $path(test1) w] fconfigure $f -encoding binary puts -nonewline $f "1234567890123\x82\x4F\x82\x50\x82" close $f set f [open $path(test1)] fconfigure $f -encoding shiftjis -profile tcl8 set x [list [gets $f line] $line] lappend x [tell $f] [testchannel inputbuffered $f] [eof $f] lappend x [gets $f line] $line close $f set x

---- Result was: 16 1234567890123\U0000FF10\U0000FF11\xEF\xBC 18 0 1 -1 {} ---- Result should have been (exact matching): 16 1234567890123\U0000FF10\U0000FF11\x82 18 0 1 -1 {} ==== io-7.3 FAILED

It doesn't look like this commit actually causes the failure, I suspect this is an already existing bug exposed by this change.

So, this ticket is meant to investigate this bug and - hopefully - fix it.

Referenced by6
jan.nijtmans Ticket [5be203d6ca]: 3 changes [History diff]2023-07-03 14:11:30
apnadkarniplain2023-07-04 06:58:42
Jan,

It was the commit that caused failure. A proposed fix is in the [bug-5be203d6ca-apn]. The root cause is that in the case of the truncated prefix byte being the last one, src is incremented again at the bottom of the loop (in addition to the one within the if (prefixByte) condition) making it point beyond srcEnd. The result computation of *srcReadPtr is then obviously wrong.

However, this fix is not final.

First, other decoding functions need to be checked for the same error.

More important, it is not clear to me now why the original code where src was being decremented earlier (as in 8.6) caused the assertion failures in the tests. Is it possible the assertion is itself wrong? I don't understand the io system enough to make a call on that.

/Ashok
jan.nijtmanswiki2023-07-04 09:22:49

Thanks for taking this! I'm as puzzled as you are.

apnadkarniplain2023-07-04 09:52:03
Will do.

It is very discomforting that the tclIO code seems to disregard return status from the Tcl encoding functions more often than not. But that's a separate issue.

/Ashok
apnadkarniplain2023-07-05 06:18:43
Purported fix is in [7a68ac2af7] (8.7) and [4b6fd44d84] (9.0)
oehharwiki2023-07-05 06:28:37

Great work !

Why do you have ind generic/tclEncoding.c line 3480:

if (src >= srcEnd-1) {

and not

if (src > srcEnd) {

Is it the unsigned size_t type?

Do I miss something? Thanks, Harald

apnadkarniplain2023-07-05 06:39:03
The two are not equivalent.

src > srcEnd is same as src >= srcEnd+1, not src >= srcEnd-1

Happens :-)
apnadkarni Closed ticket [5be203d6ca]. [History diff]2023-07-05 10:20:26
Log in (anonymous is fine) to add a comment.