Skip to content
Tcl Source Code View Ticket
Login

View Ticket

tcl Tcl_CreateTimerHandler has flaws which may never invoker input function

Openf9764cd7a938fca3a91b087a6a5bd635cea1a216Created 3 years agoUpdated 3 years ago
Descriptionmarkdown2023-09-21 15:08:44

Current date:Thu Sep 21 02:55:28 PM UTC 2023 Step1: cat << EOF > test.sh #!/usr/bin/expect

sleep 10

EOF

Step2: date -s "Thu Sep 14 20:13:49 CST 2138" ; expect -d test.sh &

Step3: date -s "Thu Sep 14 20:13:49 CST 2023"

Expected behaviour

'expect -d test.sh' will be executed after 10 seconds.

Real outcome

'expect -d test.sh' not executed until 7 days later (Sep 14 to Sep 21)

Possible fix

I think this is becuase expect software uses Tcl_CreateTimerHandler()function, which use absolutetime to measure how many seconds to wait before invoking function. And the amoung of seconds to wait can be changed by modifying current date of OS system.

Question is: is this an expected behavior of TCL? And change the Tcl_GetTime() function to retrieve relative time by using CLOCK_MONOTONIC

Log in (anonymous is fine) to add a comment.