Skip to content

Assertion failure with multiple threads & legacy opcode tracing in free-threaded build #118415

@chgnrdv

Description

@chgnrdv

Crash report

What happened?

Bisected to 33da0e8.

import sys
import threading

def trace(frame, event, arg):
    frame.f_trace_opcodes = True
    return trace

sys.settrace(trace)

l = threading._RLock()

def f():
    while True:
        with l:
            pass

t = threading.Thread(target=f)
t.start()
while True:
    with l:
        pass
t.join()
$ ./python -X faulthandler -X gil=0 repro.py
python: Python/instrumentation.c:1216: _Py_call_instrumentation_line: Assertion `is_version_up_to_date(code, tstate->interp)' failed.
Fatal Python error: Aborted

Current thread 0x00007f7bc3712700 (most recent call first):
  File "/home/radislav/projects/cpython/Lib/threading.py", line 209 in acquire
  File "/home/radislav/projects/cpython/repro.py", line 14 in f
  File "/home/radislav/projects/cpython/Lib/threading.py", line 990 in run
  File "/home/radislav/projects/cpython/Lib/threading.py", line 1039 in _bootstrap_inner
  File "/home/radislav/projects/cpython/Lib/threading.py", line 1010 in _bootstrap

Thread 0x00007f7bc39fb280 (most recent call first):
  File "/home/radislav/projects/cpython/Lib/threading.py", line 206 in acquire
  File "/home/radislav/projects/cpython/repro.py", line 20 in <module>
Aborted (core dumped)

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

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

Python 3.13.0a6+ (heads/main:5a90de0d4c, Apr 30 2024, 00:01:27) [GCC 10.2.1 20210110]

Linked PRs

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions