Skip to content

Tracing functions doesn't not communicate to installed functions that they will be substituted #138794

@pablogsal

Description

@pablogsal

Bug report

Bug description:

When tracing, profiling, or object tracing functions are installed in CPython, they are not notified if another function is later installed to replace them. This is particularly bad for ref tracker hooks as this means that existing tracers may continue referencing objects they believe are still alive, even though they never receive deallocation events, creating the risk of dangling references and inconsistent state.

The proposed solution is to emit a special event whenever a new tracing or profiling function is installed, so that currently active functions can react appropriately (e.g., cleaning up resources or releasing references) before being substituted.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions