Artifacts Associated With Ticket 0221b993a1
Ticket change [fe96ef9449] (rid 192562) by erikleunissen on 2021-03-15 19:09:33:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Nonwithstanding the intention in the comment, the following code snippet from Tcl_DoOneEvent(): /* * If idle events are the only things to service, skip the main part * of the loop and go directly to handle idle events (i.e. don't wait * even if TCL_DONT_WAIT isn't set). */ if ((flags & TCL_ALL_EVENTS) == TCL_IDLE_EVENTS) { flags = flags | TCL_DONT_WAIT; goto idleEvents; } is bypassed for [update idletasks] because of the presence of the TCL_WINDOW_EVENTS bit in the flags argument, which Tcl_DoOneEvent() receives from Tcl_UpdateObjCmd(): switch ((enum updateOptions) optionIndex) { case OPT_IDLETASKS: flags = TCL_WINDOW_EVENTS|TCL_IDLE_EVENTS|TCL_DONT_WAIT; <=== *** break; default: Tcl_Panic("Tcl_UpdateObjCmd: bad option index to UpdateOptions"); } I find the presence of TCL_WINDOW_EVENTS in that flags variable suspect. What window events anyway? Especially when comparing with the Tk counterpart Tk_UpdateObjCmd(). In Tk, windows do play a role, but even here the TCL_WINDOW_EVENTS bit is not passed when "update idletasks" is invoked: if (objc == 1) { flags = TCL_DONT_WAIT; } else if (objc == 2) { if (Tcl_GetIndexFromObj(interp, objv[1], updateOptions, "option", 0, &index) != TCL_OK) { return TCL_ERROR; } flags = TCL_IDLE_EVENTS; <=== *** } else { Tcl_WrongNumArgs(interp, 1, objv, "?idletasks?"); return TCL_ERROR; } - foundin initialized to: "8.6.11"
- is_private initialized to: "0"
- login: "erikleunissen"
- priority initialized to: "5 Medium"
- private_contact initialized to: "609f4c7ecf7dbb7a46acdc7eb164753d196088a6"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "erikleunissen"
- subsystem initialized to: "02. Event Loops"
- title initialized to:
Tcl command [update idletasks] doesn't skip main loop in Tcl_DoOneEvent
- type initialized to: "Bug"
Ticket change [fd6019712d] (rid 192563) by erikleunissen on 2021-03-15 19:33:44:
- icomment:
If I am right, the consequence is that all along [update idletasks] has been servicing events from sources that it should ignore: timer events and file events. Therefore, upgrading priority to important.
- login: "erikleunissen"
- mimetype: "text/plain"
- severity changed to: "Important"
- icomment:
Ticket change [854b5d348e] (rid 192564) by erikleunissen on 2021-03-15 19:34:41:
- icomment:
> Therefore, upgrading priority to important. Uhmm, I mean: severity
- login: "erikleunissen"
- mimetype: "text/plain"
- icomment:
Ticket change [f755148d51] (rid 192574) by erikleunissen on 2021-03-16 18:15:36:
- icomment:
Corroborating the misbehaviour: I've put a printf() inside the crucial code snippet in Tcl_DoOneEvent(), like: if ((flags & TCL_ALL_EVENTS) == TCL_IDLE_EVENTS) { printf("***\n"); flags = TCL_IDLE_EVENTS | TCL_DONT_WAIT; goto idleEvents; } This printf() is skipped by [update idletasks] in a tclsh, but after loading Tk (which has a different implementation of the "update" command), the printf() statement is executed. This confirms my suspicion, that [update idletasks], called from tclsh (no Tk loaded) doesn't skip what it should skip inside Tcl_DoOneEVent(). The consequences are probably not as severe as that it services timer and file events, but it does carry out a bunch of useless work (harmful work not excluded), like checking inappropriate event sources. The remedy is simple (stripping the offending TCL_WINDOW_EVENTS inside Tcl_UpdateObjCmd() ). A patch (against tcl8.6.11) is provided anyway to prevent any ambiguity. - login: "erikleunissen"
- mimetype: "text/plain"
- icomment:
Add attachment "idletasks-bug.patch" [39b1419a6f] (rid 192575) by erikleunissen on 2021-03-16 18:16:17.
Ticket change [0059db5672] (rid 192580) by jan.nijtmans on 2021-03-17 08:30:23:
- assignee changed to: "jan.nijtmans"
- icomment:
Since TCL_WINDOW_EVENTS are really Tk events, I see no harm in removing TCL_WINDOW_EVENTS, as @erikleunissen suggests. Still, to prevent any risk (maybe other extensions could register TCL_WINDOW_EVENTS ...) I suggest to make this change only in Tcl 8.7+. Any objections?
- login: "jan.nijtmans"
- mimetype: "text/plain"
Ticket change [8d97ab88f4] (rid 192623) by jan.nijtmans on 2021-03-18 13:21:29:
- icomment:
Proposal now committed to the "bug-0221b993a1" branch
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- resolution changed to: "Fixed"
- status changed to: "Pending"
- icomment:
Ticket change [4387c12b54] (rid 192698) by jan.nijtmans on 2021-03-19 15:01:33:
- closedate changed to: "2459293.12608196"
- closer changed to: "jan.nijtmans"
- icomment: "Merged to core-8-branch and trunk"
- login: "jan.nijtmans"
- mimetype: "text/x-fossil-wiki"
- status changed to: "Closed"
Ticket change [a1e4dfd7fc] (rid 194641) by dgp on 2021-06-04 20:28:02:
- closedate changed to: "2459370.35280528"
- closer changed to: "dgp"
- icomment:
Should tcl.h continue to define TCL_WINDOW_EVENTS ? Should there continue to be a testing subcommand [testfilehandler windowevent] ?
- login: "dgp"
- mimetype: "text/plain"