diff options
| author | oehhar <harald.oehlmann@elmicron.de> | 2023-11-13 15:35:55 (GMT) |
|---|---|---|
| committer | oehhar <harald.oehlmann@elmicron.de> | 2023-11-13 15:35:55 (GMT) |
| commit | d0863453ccc9e881f12f9015c72a94533dec5267 (patch) | |
| tree | f4e88bf027c7cb0a9342fb277d60297333fb9600 /generic/tclIO.c | |
| parent | ffbbb271c1e907ee78e03e8e62398559a0d6c74b (diff) | |
| parent | f2f65837424c0c2203228c46a3274edff4eb9265 (diff) | |
| download | tcl-d0863453ccc9e881f12f9015c72a94533dec5267.zip tcl-d0863453ccc9e881f12f9015c72a94533dec5267.tar.gz tcl-d0863453ccc9e881f12f9015c72a94533dec5267.tar.bz2 | |
Bug [c4eb46a1]: endless loop on non blocking gets with encoding error. Now, tests zlib-8.21 and zlib-8.22 fail with unknown reason, but better than a hang.
Diffstat (limited to 'generic/tclIO.c')
| -rw-r--r-- | generic/tclIO.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 6461909..bc1b1c6 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -4749,6 +4749,12 @@ Tcl_GetsObj( ResetFlag(statePtr, CHANNEL_BLOCKED); while (1) { if (dst >= dstEnd) { + /* + * In case of encoding errors, state gets flag + * CHANNEL_ENCODING_ERROR set in the call below. First, the + * EOF/EOL condition is checked, as we may have valid data with + * EOF/EOL before the encoding error. + */ if (FilterInputBytes(chanPtr, &gs) != 0) { goto restore; } @@ -4918,8 +4924,17 @@ Tcl_GetsObj( } goto gotEOL; } else if (gs.bytesWrote == 0 - && GotFlag(statePtr, CHANNEL_ENCODING_ERROR) - && !GotFlag(statePtr, CHANNEL_NONBLOCKING)) { + && GotFlag(statePtr, CHANNEL_ENCODING_ERROR)) { + /* Ticket c4eb46a1 Harald Oehlmann 2023-11-12 debugging session. + * In non blocking mode we loop indifenitly on a decoding error in + * this while-loop. + * Removed the following from the upper condition: + * "&& !GotFlag(statePtr, CHANNEL_NONBLOCKING)" + * In case of an encoding error with leading correct bytes, we pass here + * two times, as gs.bytesWrote is not 0 on the first pass. This feels + * once to much, as the data is anyway not used. + */ + /* 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 |
