Overview
| Artifact ID: | 0ae3cc285e7e9026591d265c29ec38ac4a9a725ce48d208a3ea3c1766c26c4a3 |
|---|---|
| Ticket: | c4eb46a196227040bfb18770ac261d6836e58f0e
endless loop in gets on encoding error in non blocking mode |
| User & Date: | oehhar on 2023-11-12 19:38:27 |
Changes
- 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"