Skip to content
Tcl Source Code History Of Ticket 1464890
Login

History Of Ticket 1464890

Artifacts Associated With Ticket 1464890

  1. Ticket change [38fef3770f] (rid 112310) by jflarvoire on 2006-04-05 12:37:52:

    1. assignee initialized to: "kennykb"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Hello,
      
      I wish to reopen bug #432038, and its duplicate bug
      #1052859:
      
      Changing the system clock hangs all Tcl events handlers
      that are scheduled with the after command.
      This makes it impossible to have reliable periodic
      handlers written in pure Tcl. (They may die
      unexpectedly anytime somebody runs the date/time command)
      
      I've just been badly hurt by this very problem on a
      large cluster we manage: We had system monitoring
      scripts written in Tcl that kept dying mysteriously on
      some of the nodes. And the illness was spreading with
      time...
      
      Contrary to what was written in a comment of bug
      #432038, using NTP does not prevent the problem:
      We saw the problem on machines with harware clocks
      slowly drifting. After each reboot, NTP takes some time
      for resynchronizing the system time... hanging all our
      Tcl scripts timers when it eventually does.
      
      Also I completely disagree with the closing comment in
      bug #1052859 about the lack of monotonically increasing
      timers in both Unix and Windows.
      The Unix sleep command, used in tons of shell scripts,
      is completely immune to such system date/time changes.
      This is easy to verify. Let's use in Tcl's after
      command the same timing function that Unix' sleep does.
      Likewise, Windows' waitable timers are immune too. I
      just verified it with the sample code for
      CreateWaitableTimer in MSDN library.
      
      Jean-François
      
    4. foundin initialized to: "None"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "jflarvoire"
    9. subsystem initialized to: "03. Timer Events"
    10. title initialized to: "after command hangs when system time changes"
    11. type initialized to: "Bug"
  2. Ticket change [c7588dd361] (rid 121914) by kennykb on 2007-03-12 23:27:51:

    1. icomment:
      Logged In: YES 
      user_id=99768
      Originator: NO
      
      The trouble with what you're demanding is that it works only if there is only one [after] active, anywhere in the program.  As soon as there is more than one, you get back into the same situation.  Certainly, you can use sleep() or a waitable timer to delay until it's time for the *first* after to wake up.  But in the situation:
      
           after 10000 {do something}
           after 5000 {do something else}
      
      once you've awakened on the first [after], you have to figure out what time the *second* one should fire.  If the clock has backed up, how do you do that and get the behaviour you demand?  Spinning a thread per [after] so that they can all use blocking timers would probably be infeasible - I know of applications that have thousands of [after]s scheduled.
      
      
    2. login: "kennykb"
    3. mimetype: "text/plain"
    4. username: "kennykb"
  3. Ticket change [ebff9c4b98] (rid 103635) by jflarvoire on 2007-03-15 16:36:30:

    1. icomment:
      Logged In: YES 
      user_id=617204
      Originator: YES
      
      What about having a surveyor thread, querying the system time every 500ms,
      and initiating a corrective action if it detects any abnormal change?
      - Any change that goes backwards in time is proof of a system clock update.
      - Any change going forward more than a given threshold is a likely update too.
        (May also be a delay due to high system load. Would have to make the surveyor
         thread a high priority thread to make it resilient to such overloads)
      
      Note that this is how we eventually fixed our problem.
      Instead of a thread, we used an outside program dedicated for that.
      Obviously an internal thread would be much more efficient.
      
      
    2. login: "jflarvoire"
    3. mimetype: "text/plain"
    4. username: "jflarvoire"
  4. Ticket change [f2377f9eb7] (rid 255475) by anonymous on 2026-08-12 16:17:15:

    1. assignee changed to: "aku"
    2. closer changed to: "nobody"
    3. comment changed to:
      Hello,
      
      I wish to reopen bug #432038, and its duplicate bug
      #1052859:
      
      Changing the system clock hangs all Tcl events handlers
      that are scheduled with the after command.
      This makes it impossible to have reliable periodic
      handlers written in pure Tcl. (They may die
      unexpectedly anytime somebody runs the date/time command)
      
      I've just been badly hurt by this very problem on a
      large cluster we manage: We had system monitoring
      scripts written in Tcl that kept dying mysteriously on
      some of the nodes. And the illness was spreading with
      time...
      
      Contrary to what was written in a comment of bug
      #432038, using NTP does not prevent the problem:
      We saw the problem on machines with harware clocks
      slowly drifting. After each reboot, NTP takes some time
      for resynchronizing the system time... hanging all our
      Tcl scripts timers when it eventually does.
      
      Also I completely disagree with the closing comment in
      bug #1052859 about the lack of monotonically increasing
      timers in both Unix and Windows.
      The Unix sleep command, used in tons of shell scripts,
      is completely immune to such system date/time changes.
      This is easy to verify. Let's use in Tcl's after
      command the same timing function that Unix' sleep does.
      Likewise, Windows' waitable timers are immune too. I
      just verified it with the sample code for
      CreateWaitableTimer in MSDN library.
      
      Jean-François
      
    4. icomment:
      In 2026 this is still super-problematic issue.
      
      Can we please agree on some kind of solution? Once the solution is ready, implementation should be easy. But there might be some need to extend the portable layer to expose the underlying OS API...
      
    5. login: "anonymous"
    6. mimetype: "text/plain"
    7. severity changed to: "Minor"
  5. Ticket change [d6da1aeb82] (rid 255477) by apnadkarni on 2026-08-13 01:42:52:

    1. icomment:
      I think [TIP 723](https://core.tcl-lang.org/tips/doc/trunk/tip/723.md) in the upcoming 9.1 addresses your use case?
      
    2. login: "apnadkarni"
    3. mimetype: "text/x-markdown"