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
2906d33993Bug [5be203d6ca] - io-7.3 failure. check-in2024-06-29 23:42:314b6fd44d84Merge 8.7 - Bug [5be203d6ca] - io-7.3 failure check-in2023-07-05 05:52:587a68ac2af7Bug [5be203d6ca] - io-7.3 failure check-in2023-07-05 05:08:56b88bf9d6bdBug [5be203d6ca] - better fix and add test check-in2023-07-05 03:23:43d70f500674Branch meant for bug-fixing [5be203d6ca]: io-7.3 and chanio-7.3 fail in debug mode check-in2023-07-03 14:16:376b6caba07aTemporary disable tests io-7.3 and chanio-7.3, which fail in debug mode. Ticket [5be203d6ca] created. check-in2023-07-03 13:46:54
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.