Skip to content

gh-145064: fix JIT tracing for non-function frames#145078

Closed
aviralgarg05 wants to merge 1 commit intopython:mainfrom
aviralgarg05:gh-145064-jit-co-null-uop-frame
Closed

gh-145064: fix JIT tracing for non-function frames#145078
aviralgarg05 wants to merge 1 commit intopython:mainfrom
aviralgarg05:gh-145064-jit-co-null-uop-frame

Conversation

@aviralgarg05
Copy link

@aviralgarg05 aviralgarg05 commented Feb 21, 2026

Summary of Changes

  • Fixed a JIT crash path for issue JIT: co != NULL assertion failure in *_Py_uop_frame_new #145064 JIT: co != NULL assertion failure in *_Py_uop_frame_new #145064 where tracing could start from non-function frames (for example init-cleanup shim frames), which could lead to invalid assumptions about function/code availability.
  • Updated /Users/aviralgarg/Everything/cpython/Python/optimizer.c:
    • Store initial_state.func only when frame->f_funcobj is a real PyFunctionObject.
    • Assert initial_state.code (always required) instead of assuming initial_state.func is always present.
  • Updated /Users/aviralgarg/Everything/cpython/Python/optimizer_analysis.c:
    • Use initial_state.code directly when creating the abstract frame.
    • Keep frame->func optional and null-safe.
  • Added regression coverage in /Users/aviralgarg/Everything/cpython/Lib/test/test_capi/test_opt.py:
    • New test: test_145064.
  • Added NEWS entry:
    • /Users/aviralgarg/Everything/cpython/Misc/NEWS.d/next/Core_and_Builtins/2026-02-21-18-10-00.gh-issue-145064.p8Nq2v.rst

Testing Logs

Local build and checks

  • Build directory: /tmp/cpython-build-145064
  • Rebuilt JIT-enabled debug interpreter multiple times:
    • make -j8 (successful)
  • Style/check run:
    • make patchcheck (completed; local output also noted expected environment state and prompted about test/refleak confirmation)

Targeted regression tests

  • New regression test run multiple times:
    • ./python.exe -m test -j1 -v test_capi.test_opt --match test_145064
    • Result: OK (run repeatedly, all passes)

Related JIT regression tests

  • ./python.exe -m test -j1 -v test_capi.test_opt --match test_143026OK
  • ./python.exe -m test -j1 -v test_capi.test_opt --match test_143092OK
  • ./python.exe -m test -j1 -v test_capi.test_opt --match test_143183OK
  • ./python.exe -m test -j1 -v test_capi.test_opt --match test_143358OK
  • ./python.exe -m test -j1 -v test_capi.test_opt --match test_144068_daemon_thread_jit_cleanupOK
  • ./python.exe -m test -j1 -v test_optimizerOK

Reproduction-command stress validation (issue command)

  • Command exercised repeatedly:
    • PYTHON_JIT=1 ./python.exe -m mypy --no-incremental --strict -c "pass"
  • Post-fix stress runs:
    • Three batches of 25 runs each (75 total): PASS batch=1, PASS batch=2, PASS batch=3
    • Additional 25-run verification batch: PASS:25

CI status observed after push

  • Branch: gh-145064-jit-co-null-uop-frame
  • Commit: 29faba9f94
  • GitHub Actions:
    • Lint workflow: success
    • JIT workflow: in progress during observation (no failures reported at the time)

@Fidget-Spinner
Copy link
Member

Did you use an LLM to generate this? That's fine if so, but please look at the devguide on this https://devguide.python.org/getting-started/generative-ai/

I don't know which model you're using, but the test is wrong, and the explanation is wrong, and the fix is also probably wrong. Sorry but I'm closing this issue to not waste reviewer time.

@aviralgarg05 aviralgarg05 deleted the gh-145064-jit-co-null-uop-frame branch February 21, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants