Assertion failure in Python/optimizer.c _PyOptimizer_Optimize in JIT #140936
Copy link
Copy link
Closed
Labels
3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Description
Crash report
What happened?
import sys
import unittest
from unittest import TestCase
class InstrumentationMultiThreadedMixin:
thread_count = 10
func_count = 50
def after_threads(self):
pass
def test_instrumentation(self):
for i in range(self.func_count):
x = {}
threads = []
for i in range(self.thread_count):
for t in threads:
break
self.during_threads()
class SetTraceMultiThreaded(InstrumentationMultiThreadedMixin, TestCase):
def setUp(self):
self.set = 2**31-1
def after_test(self):
self.assertTrue(self.called)
def tearDown(self):
sys.settrace(1023)
def trace_func(self, frame, event, arg):
return self.trace_func
def during_threads(self):
if self.set:
sys.settrace(self.trace_func)
t.join()
if __name__ == "__main__":
unittest.main()...
TypeError: 'int' object is not callable
python: ../Python/optimizer.c:121: _PyOptimizer_Optimize: Assertion `interp->jit' failed.
Aborted (core dumped)
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
No response
Linked PRs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
Activity
sergey-miryanov commentedon Nov 3, 2025
I think it would be better if you provided the building flags used to create the fuzzed version of python executable.
YuanchengJiang commentedon Nov 3, 2025
building flag:
--with-pydebug --enable-experimental-jit=yes --with-address-sanitizersergey-miryanov commentedon Nov 3, 2025
Simplified MRE:
Stacktrace to failed assert:
cc @Fidget-Spinner
Fidget-Spinner commentedon Nov 3, 2025
I can reproduce this using my new JIT frontend as well. Probably a bug in the specialization/JIT detection.
efimov-mikhail commentedon Nov 3, 2025
FYI, I've made some repro without using stdlib:
efimov-mikhail commentedon Nov 3, 2025
It seems that I've found a simple solution.
gh-140936: Fix JIT assertion crash at finalization if some generator …
pythongh-140936: Fix JIT assertion crash at finalization if some gene…
[3.14] gh-140936: Fix JIT assertion crash at finalization if some gen…
Merge branch 'main' into fix-issue21914
Merge branch 'main' of github.com:python/cpython into fix-Issue18387
Merge branch 'main' of github.com:python/cpython into fix-issue24255
pythongh-140936: Fix JIT assertion crash at finalization if some gene…