[issue33632] undefined behaviour: signed integer overflow in threadmodule.c

Martin Panter report at bugs.python.org
Sun Apr 14 02:05:46 EDT 2019


Martin Panter <vadmium+py at gmail.com> added the comment:

Victor, if you run the test suite, one of the test cases should trigger the overflow. I used to compile with Undefined Behaviour Sanitizer to print messages when these errors occur; see <https://bugs.python.org/issue1621#msg271118> for my setup at the time. I presume Antoine did something similar.

I do not remember, but suspect the test case might be the following lines of “BaseLockTests.test_timeout” in Lib/test/lock_tests.py, testing a fraction of a second less than PY_TIMEOUT_MAX:

# TIMEOUT_MAX is ok
lock.acquire(timeout=TIMEOUT_MAX)

Perhaps reducing PY_TIMEOUT_MAX by a few centuries would be one way to avoid the problem. In my patch I avoided the problem by rearranging the arithmetic, so that the timeout value is only compared and reduced, never added.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue33632>
_______________________________________


More information about the Python-bugs-list mailing list