Overview
| Artifact ID: | eea425c80e776bd1200e904af6881e5c147308a9c89ea0a36ff8f6e7af1c200f |
|---|---|
| Ticket: | 3328635fffffffffffffffffffffffffffffffff
Virtual Time broken on threaded unix |
| User & Date: | serhiy.storchaka on 2026-10-21 10:53:13 |
Changes
- foundin changed to: "9.1.0"
- icomment:
On main the timers are monotonic since TIP 723, but timed condition waits on Unix still used an absolute wall-clock deadline (default <tt>CLOCK_REALTIME</tt> condition variables, deadline from <tt>Tcl_GetDayTime()</tt>). A step of the system time during a timed wait made it longer or shorter by the size of the step. This affects every timed wait, including the 0-timeout one in zipfs init. Proposed fix in branch [/timeline?r=unix-monotonic-condwait|unix-monotonic-condwait]: condition variables are created with <tt>pthread_condattr_setclock(CLOCK_MONOTONIC)</tt> where available, and deadlines are computed on the same clock. It covers <tt>Tcl_ConditionWait()</tt> and the select notifier's wait. <tt>TclUnixWaitForFile()</tt> also uses the monotonic clock now. Without <tt>pthread_condattr_setclock()</tt> (macOS), the behavior is unchanged. Tested on Linux, FreeBSD, NetBSD, OpenBSD and OpenIndiana, with the wall clock shifted by an <tt>LD_PRELOAD</tt> shim. There is no test in the suite, since that needs a clock change.
- login: "serhiy.storchaka"
- mimetype: "text/x-fossil-wiki"