Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2026-10-22
17:19 • Ticket [8584043146] Windows: after and Tcl_Sleep can sleep about 72 minutes ... artifact: ac9480d51d user: serhiy.storchaka
2026-10-17
07:25 • Closed ticket [8584043146]. artifact: 2cfe80b848 user: serhiy.storchaka
07:21
Fix [8584043146]: Windows: after and Tcl_Sleep can sleep about 72 minutes check-in: 19fc013bb1 user: serhiy.storchaka tags: core-9-0-branch
06:51 • Ticket [8584043146] Windows: after and Tcl_Sleep can sleep about 72 minutes ... artifact: 4a9052bba4 user: jan.nijtmans
2026-10-16
22:03 • Ticket [8584043146]: 3 changes artifact: 1d50db5b31 user: serhiy.storchaka
22:02
Fix [8584043146]: on Windows, Tcl_Sleep could sleep about 72 minutes when the remaining time crossed... closed check-in: 36cffd6b29 user: serhiy.storchaka tags: win-sleep-negative-usec
22:01 • New ticket [8584043146] Windows: after and Tcl_Sleep can sleep about 72 minutes<... artifact: 708f935835 user: serhiy.storchaka

Windows: after and Tcl_Sleep can sleep about 72 minutes

Closed / Fixed858404314692d758d1aba126ac6dd0c448c1de3bCreated 47 days agoUpdated 41 days ago
Descriptionwiki2026-10-16 22:01:31
In the retry loop of Tcl_Sleep() (win/tclWinNotify.c), vdelay.usec = desired.usec - now.usec is negative when the remaining time crosses a second boundary, and (unsigned long)vdelay.usec / 1000 turns it into about 4294967 ms, so SleepEx() waits about 71.6 minutes. The loop runs when SleepEx() wakes before Tcl's clock reaches the target, which happens easily on virtual machines: a 9.0.5 tclsh and its children all hung in [after 8000] for more than 10 minutes on a Windows 11 VM.

The cast came with [837dbec7cc]. 8.6 (signed arithmetic) and 9.1 (TIP 723) are not affected.

Referenced by2
  • 19fc013bb1Fix [8584043146]: Windows: after and Tcl_Sleep can sleep about 72 minutes check-in2026-10-17 07:21:26
  • 36cffd6b29Fix [8584043146]: on Windows, Tcl_Sleep could sleep about 72 minutes when the remaining time crossed a second boundary: compute the delay in milliseconds before casting it to DWORD, as before [837dbec7cc]. check-in2026-10-16 22:02:53
serhiy.storchakawiki2026-10-16 22:03:36

Proposed fix in branch win-sleep-negative-usec (from core-9-0-branch): compute the delay before casting it to DWORD. Tested on Windows 11 with a slowed-down Tcl clock: 9.0.5 hung in 4 of 8 runs, the fixed build in none.

jan.nijtmanswiki2026-10-17 06:51:49

+1

Please go ahead

serhiy.storchakawiki2026-10-17 07:25:45

Merged into 9.0 in [19fc013bb1]. Main is not affected (TIP 723).

serhiy.storchaka Ticket [8584043146]: 3 changes [History diff]2026-10-22 17:19:27
Log in (anonymous is fine) to add a comment.