Skip to content

Assertion failure on finalization with _lsprof and asyncio in 3.12 #127836

@devdanzin

Description

@devdanzin

Crash report

What happened?

It's possible to abort the interpreter in 3.12 during finalization by having a mix of enabled _lsprof and asyncio with very specific details:

import asyncio
import _lsprof

obj = _lsprof.Profiler()
obj.enable()
obj._pystart_callback(lambda: 0, 0)
obj = None  # Required

loop = asyncio.get_event_loop()

Not having loop stored in a variable or not reassigning obj breaks the testcase.
Abort message:

python: Python/instrumentation.c:958: call_instrumentation_vector: Assertion `instrumentation_cross_checks(tstate->interp, code)' failed.
Aborted

Found using fusil by @vstinner.

CPython versions tested on:

3.12

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.12.8+ (heads/3.12:b0615a8a9aa, Dec 11 2024, 13:46:42) [GCC 11.4.0]

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.12only security fixestopic-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