python / python/cpython

IsolatedAsyncioTestCase `__del__` could be dangerous

Open
#96,021 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stdlib
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

It looks like in IsolatedAsyncioTestCase when debug() crashes it doesn't teardown the event loop, in addition it seems that if the loop isn't torn down it will happen in __del__ which means thread local sensitive functions like set_event_loop get called via the GC from potentially the wrong thread

Originally posted by @graingert in https://github.com/python/cpython/pull/95898#discussion_r946516908

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at IsolatedAsyncioTestCase and trace the debug() failure path, event-loop teardown, and del cleanup. Determine how cleanup can invoke thread-local operations from the wrong thread; done means the crash path reliably tears down the loop without unsafe destructor behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.