X Tutup
The Wayback Machine - https://web.archive.org/web/20220824114639/https://github.com/python/cpython/issues/96232
Skip to content
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

Crash in asyncio when printing a task object at teardown #96232

Open
pablogsal opened this issue Aug 24, 2022 · 1 comment
Open

Crash in asyncio when printing a task object at teardown #96232

pablogsal opened this issue Aug 24, 2022 · 1 comment

Comments

@pablogsal
Copy link
Member

pablogsal commented Aug 24, 2022

If a task object is still alive at interpreter teardown, something can try to print it. This will end in _asyncio.Future._repr_info that in turn calls:

return PyObject_CallOneArg(asyncio_future_repr_info_func, (PyObject *)self);

but asyncio_future_repr_info_func at that point can be NULL because module_free of _asynciomodule.c has been executed already, called by Py_FinalizeEx -> finalize_modules -> _PyInterpreterState_ClearModules -> ... -> module_dealloc.

The crash happens in the last _PyGC_CollectNoFail of finalize_modules so somehow the task survived the first collection and then was garbage in the second one.

I don;t have a simple repro for now, but you can get the failure by cloning https://github.com/Textualize/textual checking commit 5fe47da058564b72e5081a5658c054f55a5d85cd, installing the project and test deps and running pytest.

@pablogsal
Copy link
Member Author

pablogsal commented Aug 24, 2022

CC: @graingert

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant
X Tutup