Artifacts Associated With Ticket c4eb46a1
Ticket change [92e6b4ec64] (rid 219997) by oehhar on 2023-11-06 14:59:06:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-wiki"
- comment initialized to:
<H2>Issue</H2> *gets* hangs on a non blocking file channel when an encoding error should be reported. <H2>Example</H2> <verbatim> set f [open test_A_195_B.txt wb]; puts -nonewline $f A\xC3B; close $f set f [open test_A_195_B.txt r] fconfigure $f -encoding utf-8 -profile strict -blocking 0 gets $f </verbatim> A file is created with a non continued UTF-8 multi-byte sequence. The channel is configured to error out on encoding errors. Then, a gets in non-blocking mode is executed. TCL hangs on the *gets* line. <H2>Environment</H2> * Branch: core-8-branch, tip-653 * System: Windows 10 64 bit GER * Compiler: MS-VS 2015 on 32 bit Thank you all ! Harald
- foundin initialized to: "core-8-branch"
- is_private initialized to: "0"
- login: "oehhar"
- priority initialized to: "5 Medium"
- private_contact initialized to: "0f366eb3e9e2fcab52b8ebacd197db9047186a5f"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "oehhar"
- subsystem initialized to: "24. Channel Commands"
- title initialized to: "gets blocks on encoding error in non blocking mode"
- type initialized to: "Bug"
Ticket change [0ae3cc285e] (rid 220157) by oehhar on 2023-11-12 19:38:27:
- icomment:
A debugging session showed an endless loop in tclIO.c. The wihile-loop in line 4750 was never exited. The exit-point of the blocking case was explicitly excempted for the non blocking case. Line 4920 reads: <verbatim> } else if (gs.bytesWrote == 0 && GotFlag(statePtr, CHANNEL_ENCODING_ERROR) && !GotFlag(statePtr, CHANNEL_NONBLOCKING)) { /* Set eol to the position that caused the encoding error, and then * continue to gotEOL, which stores the data that was decoded * without error to objPtr. This allows the caller to do something * useful with the data decoded so far, and also results in the * position of the file being the first byte that was not * successfully decoded, allowing further processing at exactly that * point, if desired. */ eol = dstEnd; goto gotEOL; } </verbatim> Removing the condition for NONBLOCKING cures the endless loop. Commit [831c9a8797] in branch bug-c4eb46a1 implements this with an added test. This is successful for the error sequence "A_195_B" (as described above). Unfortunately, it is not successful for the error sequence "A\x81", what is used in the original test io-75.6. In this case, the gets returns successfully without error message. So, two tests were added for both cases (io76.6.1 and io-76.6.2) with commit [90ac5ff8f7]. - login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- username: "oehhar"
- icomment:
Ticket change [39d636733e] (rid 220193) by oehhar on 2023-11-13 16:20:20:
- icomment:
It is also effective for the 2nd error sequence. The 2nd error sequence is an incomplete UTF-8 sequence. Then, the end of file will trigger the error, which is reached by a second "gets" command. The test is adopted to this double "gets". An additional test to check the recovery capabilities is added. There, the encoding is changed to binary and the gets succeeds. The branch is merged to core-8-branch by commit [94257f6465]. Now, two new tests fail, which looks unrelated: <verbatim> ==== zlib-8.21 zlib transformation, bug f9eafc3886 FAILED ==== Contents of test case: set f [zlib push gzip [open $file w] -header [list comment \u100]] ---- Test completed normally; Return code was: 0 ---- Return code should have been one of: 1 ==== zlib-8.21 FAILED ---- zlib-8.22 start ==== zlib-8.22 zlib transformation, bug f9eafc3886 FAILED ==== Contents of test case: set f [zlib push gzip [open $file w] -header [list filename \u100]] ---- Test completed normally; Return code was: 0 ---- Return code should have been one of: 1 ==== zlib-8.22 FAILED </verbatim> I may do another debugger session to find out why. But the endless loop is cured, which is more important than a failing test. - login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- username: "oehhar"
- icomment:
Ticket change [b3c7ea141b] (rid 220197) by oehhar on 2023-11-13 16:25:52:
- closedate changed to: "2460262.18463811"
- closer changed to: "oehhar"
- icomment:
Merged to main with commit [054ebbf73b]. No additional failing tests. So, closing this ticket. Thank you all, Harald
- login: "oehhar"
- mimetype: "text/x-fossil-wiki"
- status changed to: "Closed"
- username: "oehhar"
Ticket change [7f0ae593bc] (rid 220198) by oehhar on 2023-11-13 16:27:52:
- closedate changed to: "2460262.18602682"
- login: "oehhar"
- mimetype: "text/plain"
- title changed to:
endless loop in gets on encoding error in non blocking mode