Artifacts Associated With Ticket 8419c55e2c
Ticket change [c8899efe6d] (rid 192136) by anonymous on 2021-02-27 04:08:26:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
I'm building an extension to a large and rather opaque Linux package (About which I won't say more). One of the things I knew from the documentation, but which I had not thought about is that the package uses timers and SIGALRM handling internally to do its house keeping and maintain its state. I saw the warning to not use SIGALRM in any calling program, but since I wasn't doing that, and was pretty sure Tcl wasn't doing that, I wasn't worried. And in fact, things work pretty well as long as I am running my tests from scripts. I noticed however, that if I had the package loaded in an interactive Tclsh so I could type things at it, Tclsh would often unexpectedly & silently exit. I finally figured out this must be whenever a SIGLARM fires and the package calls its handler function. Looking at the code in tclUnixChan.c where the Tclsh terminal read loop reads are done, I see that EINTR is not handled, even though it is handled for pipes and sockets elsewhere. If I make the following change, based on the code used for pipes and sockets, and compile a new Tclsh, it works fine. This seems like a bug to me -- is there some reason for not handling EINTR here? % diff -c tclUnixChan.c.bak tclUnixChan.c *** tclUnixChan.c.bak Fri Feb 12 13:59:13 2021 --- tclUnixChan.c Fri Feb 12 13:59:13 2021 *************** *** 253,259 **** * nonblocking, the read will never block. */ ! bytesRead = read(fsPtr->fd, buf, (size_t) toRead); if (bytesRead > -1) { return bytesRead; } --- 253,262 ---- * nonblocking, the read will never block. */ ! do { ! bytesRead = read(fsPtr->fd, buf, (size_t) toRead); ! } while ((bytesRead < 0) && (errno == EINTR)); ! if (bytesRead > -1) { return bytesRead; } - foundin initialized to: "8.6.*"
- is_private initialized to: "0"
- login: "anonymous"
- priority initialized to: "5 Medium"
- private_contact initialized to: "f453a2d8b2491bec888a11ddd709eccbaa04b032"
- resolution initialized to: "None"
- severity initialized to: "Important"
- status initialized to: "Open"
- submitter initialized to: "anonymous"
- subsystem initialized to: "55. Other Tools"
- title initialized to: "Tclsh read loop does not handle EINTR"
- type initialized to: "Bug"
Ticket change [73c9a8e3b7] (rid 192309) by jan.nijtmans on 2021-03-09 08:59:44:
- assignee changed to: "jan.nijtmans"
- login: "jan.nijtmans"
- mimetype: "text/plain"
Ticket change [a1a2f536cf] (rid 192316) by jan.nijtmans on 2021-03-09 09:23:11:
- closedate changed to: "2459282.89110377"
- closer changed to: "jan.nijtmans"
- icomment:
Thanks for your report, your analysis and the fix. Fully 100% OK! Fixed now in all active branches. Thanks!
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [98db484630] (rid 195311) by chw on 2021-08-09 21:33:32:
- closedate changed to: "2459436.39828874"
- closer changed to: "chw"
- icomment:
IMO the fix in tclUnixChan.c due to the bug report is too invasive, since it changes the entire channel behaviour on EINTR fundamentally w.r.t. earlier Tcl versions. The bug report mentions only the REPL of tclMain.c having a problem, thus a less invasive measure against signals would be to only change the REPL regarding EINTR, as can be seen in this check-in on www.androwish.org: https://www.androwish.org/home/info/0c961bcefd7ca47c
- login: "chw"
- mimetype: "text/plain"