-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Fix possible SIGSGV when asyncio.Future is created in __del__ #77804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Originally reported in MagicStack/uvloop#143 Future.__init__ shouldn't try to capture the current traceback if the interpreter is being finalized. |
Is the problem because traceback_extract_stack is NULL? But this will not fix the problem completely. For example calling repr() on a future can crash because of asyncio_future_repr_info_func == NULL. And many other operations use globals cleared in module_free(). |
It's not NULL, it's just a broken reference at that point. |
Then we should find what callable is NULL and fix the place where it is called. _PyObject_FastCallDict() should never be called with NULL. |
My understanding is that the interpreter is being shutdown and half of the objects are freed. We're still holding a reference to *something* in Python space and try calling it. The obvious fix for that is simply avoid capturing tracebacks if a Future object is created during finalization of the interpreter (it's pointless to capture it anyways at that point). |
It is okay if the fact that half of the objects are freed leads to raising exceptions. But an assertion failure is sign of bugs in Python core or the _asyncio module. PR 7080 removes one way of exposing these bugs, but bugs itself still are here, and there may be other ways of triggering a crash. Can this crash be reproduced without uvloop? What is the backtrace of the assertion failure? |
Exception ignored in: <bound method LoopWrapper.__del__ of <__main__.LoopWrapper object at 0x7fe14ec569b0>>
Traceback (most recent call last):
File "uvloop_test.py", line 13, in __del__
File "/usr/lib/python3.6/asyncio/base_events.py", line 276, in create_future
AttributeError: 'NoneType' object has no attribute 'Future' With uvloop and with Python compiled with --with-pydebug configure option, the failed assertion is mentioned in the original uvloop bug report. In particular, this assertion fails: python3.6-dbg: ../Objects/abstract.c:2300: _PyObject_FastCallDict: Assertion `func != NULL' failed. A full GDB backtrace is attached. |
There's nothing specific here to uvloop except the fact that it was compiled with Cython, so module finalization/GC pattern is slightly different to that of vanilla asyncio. Serhiy, I'm merging this PR since I'd like to avoid having segfaults in 3.7.0. Feel free to debug this further. |
Would be great to merge this in 3.7.0. The change is super safe to merge. |
The 3.7rc1 is not supposed to be tagged on the current 3.7 branch? |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: