Skip to content

JIT executor invalidation is called in unsafe ways which may deadlock #141658

@Fidget-Spinner

Description

@Fidget-Spinner

Bug report

Bug description:

We invalidate executors in the following code:

static int
force_instrument_lock_held(PyCodeObject *code, PyInterpreterState *interp)

AND

_PyMonitoring_SetEvents(int tool_id, _PyMonitoringEventSet events)

In the above functions, the world is stopped/the runtime lock is acquired. However, the JIT can invalidate executors. If the pending executors list becomes full, executors will be finalized. This in turn means arbitrary code can run which may try to acquire the runtime lock and cause a deadlock.

I discovered this while working on FT JIT.

CPython versions tested on:

3.15, 3.14, CPython main branch

Operating systems tested on:

No response

Metadata

Metadata

Labels

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

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions