From: Kefu Chai Date: Fri, 7 Feb 2020 14:44:53 +0000 (+0800) Subject: pybind/ceph_argparse: avoid int overflow X-Git-Tag: v15.1.1~498^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=711d8761849d2e252ebd72cba0784d0ee067b3ab;p=ceph.git pybind/ceph_argparse: avoid int overflow in python 2.6.8, `thread.join(timeout)` tries to convert the given timeout to PyTime, but turns out `2 << 32` overflows when python runtime converts the timeout from sec to ns. that's why the `lock.acquire()` call always fail in `Thread._wait_for_tstate_lock()`. and we end up with an alive thread after calling `thread.join()`. Signed-off-by: Kefu Chai --- diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index 4c65761f51e32..ab112e794c55a 100644 --- a/src/pybind/ceph_argparse.py +++ b/src/pybind/ceph_argparse.py @@ -1317,7 +1317,9 @@ def run_in_thread(func, *args, **kwargs): if timeout == 0 or timeout == None: # python threading module will just get blocked if timeout is `None`, # otherwise it will keep polling until timeout or thread stops. - timeout = 2 ** 32 + # wait for INT32_MAX, as python 3.6.8 use int32_t to present the + # timeout in integer when converting it to nanoseconds + timeout = (1 << (32 - 1)) - 1 t = RadosThread(func, *args, **kwargs) # allow the main thread to exit (presumably, avoid a join() on this