Skip to content

Crash in _asyncio._swap_current_task due to improper reference counting #105987

Closed
wolfi-dev/advisories
#8607

Description

@chgnrdv

First appeared in a474e04, where given function was introduced.

Repro:

import _asyncio

class DummyLoop:
    pass

class DummyTask:
    pass

l = DummyLoop()
_asyncio._swap_current_task(l, DummyTask())
t = _asyncio._swap_current_task(l, None)

Output:

Modules/gcmodule.c:461: visit_decref: Assertion "!_PyObject_IsFreed(op)" failed
Enable tracemalloc to get the memory block allocation traceback

object address  : 0x7fedad081130
object refcount : 1
object type     : 0x55f665a81fe0
object type name: dict
object repr     : Segmentation fault (core dumped)

I'm working on a fix.

Linked PRs

Activity

  1. added
    type-crashA hard crash of the interpreter, possibly with a core dump
    on Jun 22, 2023
  2. moved this from Todo to Done in asyncioon Jun 24, 2023
  3. added 3 commits that reference this issue on Jun 24, 2023
  4. vstinner commented on Oct 2, 2025

    @vstinner
    Member

    @kumaraditya303: test_issue105987() of test_asyncio.test_eager_task_factory is skipped since February, since commit 09fe550. What's the status of this test? Should it be fixed or removed?

  5. kumaraditya303 commented on Oct 3, 2025

    @kumaraditya303
    Contributor

    What's the status of this test? Should it be fixed or removed?

    Fixed it at #139538, thanks @vstinner for the reminder.

  6. added a commit that references this issue on Oct 3, 2025
  7. added a commit that references this issue on Oct 3, 2025
  8. added a commit that references this issue on Oct 3, 2025
  9. added a commit that references this issue on Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic-asynciotype-crashA hard crash of the interpreter, possibly with a core dump

    Projects

    • Status
      Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions