Overview
| Artifact ID: | 9529a5e2dae9874d0eda45c26603c3004c12e898 |
|---|---|
| Ticket: | 96c3f3b47d13052efb84fefb9328a195f407d859
No processing of after events |
| User & Date: | sbron on 2017-02-15 20:49:44 |
Changes
- icomment:
Unfortunately I think a lot of data presented here has no relationship with the problem. First of all 665544332211 is fine coming out of Tcl_GetWideIntFromObj(). Also your 64-bit example is mostly harmless. Sure, the {puts one} event fires too early, but it doesn't block other events from running at their proper times. That is the main problem I was trying to raise. What happens with 665544332211 on a 32-bit system is that the specified number of milliseconds is divided by 1000 and added to the current time in seconds. This then gets stored in a 32-bit integer. While sorting the linked list of timer events (TclCreateAbsoluteTimerHandler()), this number is treated as negative and thus ends up at the head of the list. However, when calculating the timeout for the first event in the linked list (TimerSetupProc()), the current time is subtracted, making the value a large positive number again. This blocks other events in the linked list from running for a long time. To create a similar problem on a 64-bit machine, you would have to end up with a number exceeding 1<<63 after dividing by 1000 and adding the current time. For the foreseeable future that would actually require at least a 73-bit number. Trying to use such a big number causes after to throw an error. So no big problem there. Maybe all negative values passed to after should be converted to 0 and TclCreateAbsoluteTimerHandler() should treat time->sec as an unsigned integer while sorting the linked list. Doing that will only leave a (much less severe) problem on 32-bit systems with events scheduled after 2106. They would fire at the wrong time, but won't affect other events. Catching that problem too could be done by checking that wakeup.sec + (long)(ms / 1000) actually fits in an unsigned integer. - login: "sbron"
- mimetype: "text/plain"