Title: JIT: Assertion failure in `_PyOptimizer_Optimize` · Issue #143123 · python/cpython · GitHub
Open Graph Title: JIT: Assertion failure in `_PyOptimizer_Optimize` · Issue #143123 · python/cpython
X Title: JIT: Assertion failure in `_PyOptimizer_Optimize` · Issue #143123 · python/cpython
Description: Crash report What happened? It's possible to abort a patched debug JIT build by running the code below. The interpreter must be called from a venv in which lafleur is installed as editable, likely due to that priming the GC into a state ...
Open Graph Description: Crash report What happened? It's possible to abort a patched debug JIT build by running the code below. The interpreter must be called from a venv in which lafleur is installed as editable, likely ...
X Description: Crash report What happened? It's possible to abort a patched debug JIT build by running the code below. The interpreter must be called from a venv in which lafleur is installed as editable, lik...
Opengraph URL: https://github.com/python/cpython/issues/143123
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JIT: Assertion failure in `_PyOptimizer_Optimize`","articleBody":"# Crash report\n\n### What happened?\n\nIt's possible to abort a patched debug JIT build by running the code below. The interpreter must be called from a venv in which lafleur is installed as editable, likely due to that priming the GC into a state suitable for the crash.\n\nSorry about the convoluted reproduction steps.\n\nThe necessary patch is:\n```diff\ndiff --git a/Include/internal/pycore_backoff.h b/Include/internal/pycore_backoff.h\nindex 23ca7299e0d..0289b5fee7c 100644\n--- a/Include/internal/pycore_backoff.h\n+++ b/Include/internal/pycore_backoff.h\n@@ -124,7 +124,7 @@ trigger_backoff_counter(void)\n // For example, 4095 does not work for the nqueens benchmark on pyperformance\n // as we always end up tracing the loop iteration's\n // exhaustion iteration. Which aborts our current tracer.\n-#define JUMP_BACKWARD_INITIAL_VALUE 4000\n+#define JUMP_BACKWARD_INITIAL_VALUE 63\n #define JUMP_BACKWARD_INITIAL_BACKOFF 6\n static inline _Py_BackoffCounter\n initial_jump_backoff_counter(void)\n@@ -137,7 +137,7 @@ initial_jump_backoff_counter(void)\n * Must be larger than ADAPTIVE_COOLDOWN_VALUE,\n * otherwise when a side exit warms up we may construct\n * a new trace before the Tier 1 code has properly re-specialized. */\n-#define SIDE_EXIT_INITIAL_VALUE 4000\n+#define SIDE_EXIT_INITIAL_VALUE 63\n #define SIDE_EXIT_INITIAL_BACKOFF 6\n\n static inline _Py_BackoffCounter\n```\n\nTo install lafleur as editable, first create a venv and activate it, then clone the [lafleur repo](https://github.com/devdanzin/lafleur/) and run `pip install -e /path/to/lafleur/clone`.\n\n\nThis MRE must be invoked like this:\n\n```\n/path/to/venv/with/editable/lafleur/install/bin/python mre.py\n```\n\nMRE:\n```python\nimport asyncio\nany_v2 = None\ntuple_v4 = (1, \"\")\n\ndef f1():\n class A:\n def _():...\n def __(): ...\n def ___():...\n\n class B: ...\n class C:\n def _(): ... \n class D:\n def _(): ... \n class E:\n def _(): ... \n class F:\n def _(): ... \n class G:\n def _(): ... \n class H:\n def _(): ... \n \n l = []\n for i in range(5):\n def _(): ...\n class I:\n async def _(): ...\n try:\n c = _()\n except Exception: ...\n\n def __(): ...\n class J:\n def _(): ...\n\n for _ in range(300):\n try:\n try: ValueError(\"\")\n except E: ...\n except Exception: ...\n (\n any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2,\n any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2,\n any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2,\n any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2,\n any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2,\n any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2,\n any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2, any_v2,\n any_v2, any_v2, \n )\n class K:\n def _():...\n def __(): ...\n def ___():...\n class AsyncCtx_9078:\n def _(self): ...\n async def __():\n try:\n for _ in K(10): ...\n except Exception: ...\n try:\n c = __()\n except Exception: ...\n x, *y = tuple_v4\n class L:\n def _():...\n def __(): ...\n def ___():...\n class M:\n def _(self): ...\n async def __():\n try:\n for _ in L(10): ...\n except Exception: ...\n try:\n c = __()\n except Exception: ...\n\n x, *y = x, *y = tuple_v4\n class M:\n def _():...\n def __(): ...\n def ___():...\n class N:\n def _():...\n def __(): ...\n def ___():...\n class O:\n def _(self): ...\n async def __():\n try:\n for _ in N(10): ...\n except Exception: ...\n try:\n c = __()\n except Exception: ...\n class P:\n def _():...\n def __(): ...\n def ___():...\n class Q:\n def _(self): ...\n async def __():\n try:\n with Q(): ...\n except Exception: ...\n try:\n c = __()\n except Exception: ...\n class R:\n def _(self): ...\n async def __():\n try:\n with R(): ...\n except Exception: ...\n try:\n c = __()\n except Exception: ...\n\n x, *y = x, *y = tuple_v4\n class S:\n def __init__(self, lit):\n selit = self.count = 0\n def __aiter__(self):return self\n async def __anext__(self):\n if self.count: n\n self.count += 1\n class T:\n def _(self): ...\n async def __():\n try:\n async for _ in S(10): ...\n except Exception: ...\n try:\n c = __()\n while True:\n try: c.send(None)\n except Exception: break\n except Exception: ...\n\nfor i in range(300):\n print(i)\n f1()\n```\n\nTraceback:\n```\n1\n[...]\n200\n201\npython: Python/optimizer.c:144: int _PyOptimizer_Optimize(_PyInterpreterFrame *, PyThreadState *): Assertion `_tstate->jit_tracer_state.initial_state.func != NULL' failed.\n\nProgram received signal SIGABRT, Aborted.\n\n#0 __pthread_kill_implementation (threadid=\u003coptimized out>, signo=6, no_tid=0) at ./nptl/pthread_kill.c:44\n#1 __pthread_kill_internal (threadid=\u003coptimized out>, signo=6) at ./nptl/pthread_kill.c:89\n#2 __GI___pthread_kill (threadid=\u003coptimized out>, signo=signo@entry=6) at ./nptl/pthread_kill.c:100\n#3 0x00007ffff7c45e2e in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26\n#4 0x00007ffff7c28888 in __GI_abort () at ./stdlib/abort.c:77\n#5 0x00007ffff7c287f0 in __assert_fail_base (fmt=\u003coptimized out>, assertion=\u003coptimized out>, file=\u003coptimized out>, line=\u003coptimized out>, function=\u003coptimized out>) at ./assert/assert.c:118\n#6 0x00007ffff7c3c19f in __assert_fail (assertion=\u003coptimized out>, file=\u003coptimized out>, line=\u003coptimized out>, function=\u003coptimized out>) at ./assert/assert.c:127\n#7 0x00005555563c0bd0 in _PyOptimizer_Optimize (frame=frame@entry=0x7e8ff6de5298, tstate=tstate@entry=0x555556e62830 \u003c_PyRuntime+358864>) at Python/optimizer.c:144\n#8 0x0000555555ed2e64 in stop_tracing_and_jit (tstate=0x555556e62830 \u003c_PyRuntime+358864>, frame=frame@entry=0x7e8ff6de5298) at Python/ceval.c:1405\n#9 0x0000555555e8eeed in _PyEval_EvalFrameDefault (tstate=\u003coptimized out>, frame=\u003coptimized out>, throwflag=\u003coptimized out>) at Python/generated_cases.c.h:11628\n#10 0x0000555555e6bf98 in _PyEval_EvalFrame (tstate=0x555556e62830 \u003c_PyRuntime+358864>, frame=0x7e8ff6de5220, throwflag=0) at ./Include/internal/pycore_ceval.h:119\n#11 _PyEval_Vector (tstate=\u003coptimized out>, func=\u003coptimized out>, locals=\u003coptimized out>, args=\u003coptimized out>, argcount=\u003coptimized out>, kwnames=0x0) at Python/ceval.c:2483\n#12 0x0000555555e6b9b5 in PyEval_EvalCode (co=\u003coptimized out>, globals=\u003coptimized out>, locals=0x7c7ff6e86440) at Python/ceval.c:1008\n```\n\nOutput from running with `PYTHON_LLTRACE=4 PYTHON_OPT_DEBUG=4`:\n[830_abort_lltrace_opt_debug.txt](https://github.com/user-attachments/files/24319421/830_abort_lltrace_opt_debug.txt)\n\nFound using [lafleur](https://github.com/devdanzin/lafleur/).\n\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n### Output from running 'python -VV' on the command line:\n\nPython 3.15.0a3+ (heads/main-dirty:3cc57505e53, Dec 23 2025, 19:04:15) [Clang 21.1.2 (2ubuntu6)]\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-143126\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/devdanzin","@type":"Person","name":"devdanzin"},"datePublished":"2025-12-23T22:43:40Z","url":"https://github.com/python/cpython/issues/143123"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:e0dc6938-e047-03c2-1933-9d8a757e7ee1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A830:D4E59:1135A92:15A01E8:6B023A99 |
| html-safe-nonce | 93bbef2fd4e062df501681d9059326fad46604476d254407ef612c6fe4f292a5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBODMwOkQ0RTU5OjExMzVBOTI6MTVBMDFFODo2QjAyM0E5OSIsInZpc2l0b3JfaWQiOiIyNDcxMTA0Njk4MTk5OTgwNjk3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | b9a64328c44287e321329d4fb9db86b4bee2da42063bccdba84867b239870e97 |
| hovercard-subject-tag | issue:3758739725 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/143123/issue_layout |
| twitter:image | https://opengraph.githubassets.com/16bbff8f1eac173449f7b4f6bd36cd90058b75333f9719fdf83cf45712330295/python/cpython/issues/143123 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/16bbff8f1eac173449f7b4f6bd36cd90058b75333f9719fdf83cf45712330295/python/cpython/issues/143123 |
| og:image:alt | Crash report What happened? It's possible to abort a patched debug JIT build by running the code below. The interpreter must be called from a venv in which lafleur is installed as editable, likely ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | devdanzin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width