classification
Title: threading.TIMEOUT_MAX integer overflow on 32-bit builds with threading.Thread.join
Type: behavior Stage:
Components: Versions: Python 3.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Arun Sharma, ZackerySpytz
Priority: normal Keywords:

Created on 2019-07-23 23:42 by Arun Sharma, last changed 2019-07-24 03:19 by ZackerySpytz.

Files
File name Uploaded Description Edit
timeout_max_32_bit.py Arun Sharma, 2019-07-23 23:42 Demonstration of timeout's immediate return
Messages (2)
msg348358 - (view) Author: Arun Sharma (Arun Sharma) Date: 2019-07-23 23:42
threading's TIMEOUT_MAX constant causes overflows when used as the timeout for threading.Thread.join on a 32-bit platform, like a Raspberry PI running Raspbian (2019-07-10-raspbian-buster).

The underlying code uses sem_timedwait.  The timespec on this platform resolves seconds to a 32-bit integer, adding the current time to the timeout to get a deadline.

====
>>> import threading
>>> threading.TIMEOUT_MAX
9223372036.0
====

The deadline is larger than the int32 UNIX Epoch and results in an overflow.

Just changing the threading.TIMEOUT_MAX to be based on the time left until the UNIX Epoch would require changing the timeout over the duration of the program and would not be very viable as the Epoch gets closer.
msg348361 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2019-07-24 03:19
See also bpo-33632.
History
Date User Action Args
2019-07-24 03:19:40ZackerySpytzsetnosy: + ZackerySpytz
messages: + msg348361
2019-07-23 23:42:44Arun Sharmacreate