#3016 Interp limit functionality with vwait call

obsolete: 8.5a2

It seems that vwait will not break when timeout
limit is hit. The following script does not stop:

set testvar ""
interp limit {} time -seconds 5
vwait testvar


  • Logged In: NO

    Small addition - first time this problem appeared when I
    tryed to break script execution from C code by setting
    further execution time to one second - result was the
    P.S. Probably it would be handy to have
    "Tcl_SetLimitExceeded" to break executing script


  • Don Porter
    Don Porter

    • labels: 105684 --> 20. [interp]
    • assigned_to: dgp --> dkf
  • Logged In: YES

    Yeah, I've known about this issue for a while. Not sure how
    to fix it yet though.

  • Logged In: YES

    Examining what I've done so far, setting up a no-action
    timer with Tcl_CreateTimerHandler will be sufficient; that
    can be done at the same time as the creation of the time limit.

  • Logged In: NO

    This doesn't seems to work, TimerHandler call doesn't
    seems to activate timeout check even with time
    granularity 1. Possible further problems - there are cases
    when timeout limit check is called too rarely, so it can be
    handy to force such a check each second. Imho, this can
    be done by changing waiting loops (Tcl_Sleep and
    Tcl_DoEvent) to do a limited wait, calling Tcl_CheckLimits
    from time to time without checking time granularity.

    Also I've found a small bug with time limits.
    Tcl_SetTimeLimit sets relative timeout while
    Tcl_CheckLimits check absolute timeout. Changes in
    Tcl_SetTimeLimit like
    usec = iPtr->limit.time.usec + now.usec;
    iPtr->limit.time.sec += now.sec + usec / 1000000;
    iPtr->limit.time.usec = usec % 1000000;
    iPtr->limit.exceeded &= ~TCL_LIMIT_COMMANDS;
    works, but when You call
    puts "Limit is: [ interp limit {} time ]"
    from script You'll get absolute timeouts, what can be


  • Logged In: YES

    There was a minor error (wrong comparison operator!) in the
    time limit evaluation code that made it postpone enforcing
    the limit until the end of the second. :^}

    Fixing blocking [after] is unpleasant, but fairly

    Fixing blocking [exec] (or other blocking IO) is beyond what
    I understand how to do at the moment. :^(

    • status: open --> closed-fixed
  • Logged In: YES

    Fixed [vwait], [update] and [after <num>] to be time-limit

    The fix for [vwait] and [update] is elegant (a timer event
    that checks the limit at the time when the limit is expected
    to be exceeded) and the fix for blocking [after] is not
    (fragment the blocking wait!) but all cases should now work.

    Thanks for reporting this!