-
Jason Madden authored
First the crash report: ``` testInterruptedRecvmsgTimeout (__main__.InterruptedRecvTimeoutTest) ... Traceback (most recent call last): File "/home/travis/build/gevent/gevent/src/gevent/_ffi/loop.py", line 83, in python_callback def python_callback(self, handle, revents): File "/home/travis/build/gevent/gevent/src/greentest/3.6/test_socket.py", line 3698, in <lambda> lambda signum, frame: 1 / 0) ZeroDivisionError: division by zero Fri Dec 15 16:09:36 2017 ok testInterruptedSendTimeout (__main__.InterruptedSendTimeoutTest) ... Fatal Python error: ffi.from_handle() detected that the address passed points to garbage. If it is really the result of ffi.new_handle(), then the Python object has already been garbage collected Thread 0x00002b26d4c01700 (most recent call first): File "/home/travis/build/gevent/gevent/src/gevent/_threading.py", line 152 in wait File "/home/travis/build/gevent/gevent/src/gevent/_threading.py", line 436 in get File "/home/travis/build/gevent/gevent/src/gevent/threadpool.py", line 200 in _worker Thread 0x00002b26d4a00700 (most recent call first): File "/home/travis/build/gevent/gevent/src/gevent/_threading.py", line 152 in wait File "/home/travis/build/gevent/gevent/src/gevent/_threading.py", line 436 in get File "/home/travis/build/gevent/gevent/src/gevent/threadpool.py", line 200 in _worker Current thread 0x00002b26cc7b2a00 (most recent call first): File "/home/travis/build/gevent/gevent/src/gevent/_ffi/loop.py", line 178 in python_stop File "/home/travis/build/gevent/gevent/src/gevent/libuv/loop.py", line 289 in run File "/home/travis/build/gevent/gevent/src/gevent/hub.py", line 688 in run ``` The main problem turned out to be the way in which libuv reports signals at random times, much worse than the way libev does. This led to callback functions unexpectedly returning 0, because that's the default for an unhandled exception or an onerror handler that returns None. That in turn led to calls to python_stop that we weren't expecting using a handle that had already been deallocated. The fix is to both be defensive about what handles we try to use, and to be more explicit about our error returns.
b2e6142c