Skip to content
Tcl Source Code History Of Ticket 0221b993a19fd8d1
Login

History Of Ticket 0221b993a19fd8d1

Artifacts Associated With Ticket 0221b993a19fd8d1

  1. Ticket change [fe96ef9449] (rid 192562) by erikleunissen on 2021-03-15 19:09:33:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. 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;
          }
      
    5. foundin initialized to: "8.6.11"
    6. is_private initialized to: "0"
    7. login: "erikleunissen"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "609f4c7ecf7dbb7a46acdc7eb164753d196088a6"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "erikleunissen"
    14. subsystem initialized to: "02. Event Loops"
    15. title initialized to:
      Tcl command [update idletasks] doesn't skip main loop in Tcl_DoOneEvent
      
    16. type initialized to: "Bug"
  2. Ticket change [fd6019712d] (rid 192563) by erikleunissen on 2021-03-15 19:33:44:

    1. 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.
      
    2. login: "erikleunissen"
    3. mimetype: "text/plain"
    4. severity changed to: "Important"
  3. Ticket change [854b5d348e] (rid 192564) by erikleunissen on 2021-03-15 19:34:41:

    1. icomment:
      > Therefore, upgrading priority to important.
      
      Uhmm, I mean: severity
      
    2. login: "erikleunissen"
    3. mimetype: "text/plain"
  4. Ticket change [f755148d51] (rid 192574) by erikleunissen on 2021-03-16 18:15:36:

    1. 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.
      
    2. login: "erikleunissen"
    3. mimetype: "text/plain"
  5. Add attachment "idletasks-bug.patch" [39b1419a6f] (rid 192575) by erikleunissen on 2021-03-16 18:16:17.

  6. Ticket change [0059db5672] (rid 192580) by jan.nijtmans on 2021-03-17 08:30:23:

    1. assignee changed to: "jan.nijtmans"
    2. 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?
      
    3. login: "jan.nijtmans"
    4. mimetype: "text/plain"
  7. Ticket change [8d97ab88f4] (rid 192623) by jan.nijtmans on 2021-03-18 13:21:29:

    1. icomment:
      Proposal now committed to the "bug-0221b993a1" branch
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "Fixed"
    5. status changed to: "Pending"
  8. Ticket change [4387c12b54] (rid 192698) by jan.nijtmans on 2021-03-19 15:01:33:

    1. closedate changed to: "2459293.12608196"
    2. closer changed to: "jan.nijtmans"
    3. icomment: "Merged to core-8-branch and trunk"
    4. login: "jan.nijtmans"
    5. mimetype: "text/x-fossil-wiki"
    6. status changed to: "Closed"
  9. Ticket change [a1e4dfd7fc] (rid 194641) by dgp on 2021-06-04 20:28:02:

    1. closedate changed to: "2459370.35280528"
    2. closer changed to: "dgp"
    3. icomment:
      Should tcl.h continue to define TCL_WINDOW_EVENTS ?
      
      Should there continue to be a testing subcommand [testfilehandler windowevent] ?
      
    4. login: "dgp"
    5. mimetype: "text/plain"