Artifacts Associated With Ticket bda99f2393
Ticket change [0ef6a0e73d] (rid 222340) by juliannoble2 on 2024-02-19 06:35:26:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/x-fossil-plain"
- comment initialized to:
Seems to affect Windows only. (tested 8.7a6 and 9.0b in ubuntu under WSL and not affected, reported by stevel as not a problem on macos) when stdin is in line mode but the channel is configured with -blocking 0 - gets fails to return a line when input is above 100 characters. The state of -translation auto/cr/lf/crlf doesn't seem to make any difference. (chan pending stdin input will show there are bytes available after hitting enter - but gets returns -1) This is most easily seen in a tclsh shell which behaves differently on windows Tcl 8.7a6/9.0b compared to 8.7a5 and earlier, and is different to Tcl on other platforms. The string repeat is just to show line of the right length. The first set v line is just shy of 100 chars of input - and hitting return brings you straight to the prompt as expected. The second set v appears to hang after enter is pushed, but hitting enter a second time, or any other key will return to the prompt. If enter was pushed, you get a double prompt. If another key was pushed - the repl prepends that character to the next commandline entered - usually resulting in an invalid command error. (although the extra character is only visible above the % on the previous line or to the left of the % depending on which terminal is being used) While running the standard repl with stdin set to line mode and nonblocking might not be usual - this behaviour of gets and stdin is potentially confusing/a source of bugs in other contexts. %chan conf stdin -blocking 0 % string repeat a 102 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa % set v aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa % set v aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa % % - foundin initialized to: "8.7a6 - 9.0b"
- is_private initialized to: "0"
- login: "juliannoble2"
- priority initialized to: "5 Medium"
- private_contact initialized to: "957fdfcd8744611e3fe1f4896c7538b1d9bf47b2"
- resolution initialized to: "None"
- severity initialized to: "Severe"
- status initialized to: "Open"
- submitter initialized to: "juliannoble2"
- subsystem initialized to: "25. Channel System"
- title initialized to: "gets stdin problem when non-blocking - Windows"
- type initialized to: "Bug"
Ticket change [e4acfe6c97] (rid 222341) by apnadkarni on 2024-02-19 11:09:50:
- assignee changed to: "apnadkarni"
- login: "apnadkarni"
- mimetype: "text/plain"
Ticket change [b07406a246] (rid 222342) by apnadkarni on 2024-02-19 12:39:54:
- icomment:
8.7/9.0 console driver uses a temporary buffer size of 200 (100 chars) while 8.6 uses a buffer size of 8192. The simple immediate "fix" seems to be to bump up the 9.0 buffer size (only one per process) to 8192 as in 8.6. However, I suspect that is just "postponing" the problem to entering 8192/2 characters so need to investigate further. In theory, the reads are supposed to read in buffer size chunks (e.g. 200 as of now) and pass them to Tcl piecemeal so the buffer size should not matter. Investigating further...
- login: "apnadkarni"
- mimetype: "text/plain"
- severity changed to: "Important"
- icomment:
Ticket change [6848c98d13] (rid 222362) by apnadkarni on 2024-02-20 06:19:40:
- icomment:
There were two issues. Recording for posterity. First, PeekConsoleInput was being used to check if there is input. It turns out this Win32 API only checks the console input records that have not yet been converted to text. So for example in the bug report, if the entered line was 110 characters, the ReadConsole with a buffer size of 200 (100 characters) would return 100 characters and store the remaining 10 internally for the next read. The console's input record queue would be empty so when the Tcl console driver called PeekConsoleInput, it would report no input pending. Entering another character would create a input record, thereby having the Peek indicate input and triggering a read. To fix this, the Tcl console read thread will now immediately trigger another read if the previous read completely filled the passed buffer. Tested with manually reducing read buffer size down to 20 bytes (since the fix below requires increasing buffer size for a different reason). The second issue, not reported above but mentioned on the chat is the limit of 254 characters on input lines. It seems ReadConsole will limit line lengths to the max of 256 (including crlf) and the supplied buffer size (easily checked via a simple console program). There does not seem any way around this so now the buffer size has been bumped back to 8192 as in 8.6. Note this is a single allocation *per process* in 9.0 as opposed to *per thread* in 8.6, so impact should be minimal.
- login: "apnadkarni"
- mimetype: "text/x-markdown"
- icomment:
Ticket change [79ad6c05e1] (rid 222384) by apnadkarni on 2024-02-23 07:33:43:
- icomment:
Julian, Could you try the code in the apn-bug-bda99f2393 branch to see if it fixes your reported issues? Also, any other issues that might show up with your in-development custom console? /Ashok
- login: "apnadkarni"
- mimetype: "text/plain"
- icomment:
Ticket change [e45372a594] (rid 222396) by apnadkarni on 2024-02-26 05:48:56:
- closedate changed to: "2460366.74232122"
- closer changed to: "apnadkarni"
- icomment: "Purportedly fixed in [7d3bfe817b]."
- login: "apnadkarni"
- mimetype: "text/x-fossil-plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [a39512fbfd] (rid 225581) by jan.nijtmans on 2024-05-07 15:21:24:
- closedate changed to: "2460438.13986795"
- closer changed to: "jan.nijtmans"
- icomment: "Should this be backported to 8.6 and 8.7 as well?"
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
Ticket change [d2c034d0c4] (rid 225585) by apnadkarni on 2024-05-07 16:06:21:
- closedate changed to: "2460438.17108787"
- closer changed to: "apnadkarni"
- icomment:
8.6 uses a different architecture (3 stdio threads per Tcl thread). Not affected by this. 8.7 is affected. /Ashok
- login: "apnadkarni"
- mimetype: "text/plain"
Ticket change [0ebc83e12f] (rid 225612) by jan.nijtmans on 2024-05-08 15:03:26:
- closedate changed to: "2460439.1273886"
- closer changed to: "jan.nijtmans"
- icomment:
I forgot: Already backported to 8.7 [770221ff549fbbf6|here]
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"