Title: Crash (Sigsev) in JIT optimizer `_GUARD_LOAD_SUPER_ATTR_METHOD` · Issue #148618 · python/cpython · GitHub
Open Graph Title: Crash (Sigsev) in JIT optimizer `_GUARD_LOAD_SUPER_ATTR_METHOD` · Issue #148618 · python/cpython
X Title: Crash (Sigsev) in JIT optimizer `_GUARD_LOAD_SUPER_ATTR_METHOD` · Issue #148618 · python/cpython
Description: Bug report Bug description: The JIT optimizer crashes with a NULL pointer dereference (SIGSEGV at address 0x8) when tracing a polymorphic super().method() call site that has been observed with multiple different class types. How to repro...
Open Graph Description: Bug report Bug description: The JIT optimizer crashes with a NULL pointer dereference (SIGSEGV at address 0x8) when tracing a polymorphic super().method() call site that has been observed with mult...
X Description: Bug report Bug description: The JIT optimizer crashes with a NULL pointer dereference (SIGSEGV at address 0x8) when tracing a polymorphic super().method() call site that has been observed with mult...
Opengraph URL: https://github.com/python/cpython/issues/148618
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash (Sigsev) in JIT optimizer `_GUARD_LOAD_SUPER_ATTR_METHOD`","articleBody":"# Bug report\n\n### Bug description:\n\nThe JIT optimizer crashes with a NULL pointer dereference (SIGSEGV at address `0x8`) when tracing a polymorphic `super().method()` call site that has been observed with multiple different class types.\n\n## How to reproduce\n\nSave the following as `poc_stale_super_ptr.py` and run with JIT stress mode:\n\n```bash\n./python.exe --version\nPython 3.15.0a8+\n\nPYTHON_JIT=0 ./python.exe poc_stale_super_ptr.py\n# -> exit 0, no crash\n\nPYTHON_JIT_STRESS=1 ./python.exe poc_stale_super_ptr.py\nzsh: segmentation fault PYTHON_JIT_STRESS=1 ./python.exe poc_stale_super_ptr.py\n```\n\n\u003cdetails>\n\u003csummary>poc_stale_super_ptr.py\u003c/summary>\n\n_Disclaimer: The PoC has been generated by an AI assistant, and I verified it worked on both my computer and a remote VM_\n\n```python\nclass Base:\n def method(self):\n return 1\n\n# 30 sibling classes each overriding method() with super().method()\nclass C0(Base):\n def method(self): return super().method() + 1\nclass C1(Base):\n def method(self): return super().method() + 1\nclass C2(Base):\n def method(self): return super().method() + 1\nclass C3(Base):\n def method(self): return super().method() + 1\nclass C4(Base):\n def method(self): return super().method() + 1\nclass C5(Base):\n def method(self): return super().method() + 1\nclass C6(Base):\n def method(self): return super().method() + 1\nclass C7(Base):\n def method(self): return super().method() + 1\nclass C8(Base):\n def method(self): return super().method() + 1\nclass C9(Base):\n def method(self): return super().method() + 1\nclass C10(Base):\n def method(self): return super().method() + 1\nclass C11(Base):\n def method(self): return super().method() + 1\nclass C12(Base):\n def method(self): return super().method() + 1\nclass C13(Base):\n def method(self): return super().method() + 1\nclass C14(Base):\n def method(self): return super().method() + 1\nclass C15(Base):\n def method(self): return super().method() + 1\nclass C16(Base):\n def method(self): return super().method() + 1\nclass C17(Base):\n def method(self): return super().method() + 1\nclass C18(Base):\n def method(self): return super().method() + 1\nclass C19(Base):\n def method(self): return super().method() + 1\nclass C20(Base):\n def method(self): return super().method() + 1\nclass C21(Base):\n def method(self): return super().method() + 1\nclass C22(Base):\n def method(self): return super().method() + 1\nclass C23(Base):\n def method(self): return super().method() + 1\nclass C24(Base):\n def method(self): return super().method() + 1\nclass C25(Base):\n def method(self): return super().method() + 1\nclass C26(Base):\n def method(self): return super().method() + 1\nclass C27(Base):\n def method(self): return super().method() + 1\nclass C28(Base):\n def method(self): return super().method() + 1\nclass C29(Base):\n def method(self): return super().method() + 1\n\n# 5-deep inheritance chain\nclass D0(Base):\n def method(self): return super().method() + 1\nclass D1(D0):\n def method(self): return super().method() + 1\nclass D2(D1):\n def method(self): return super().method() + 1\nclass D3(D2):\n def method(self): return super().method() + 1\nclass D4(D3):\n def method(self): return super().method() + 1\n\nALL = [\n C0, C1, C2, C3, C4, C5, C6, C7, C8, C9,\n C10, C11, C12, C13, C14, C15, C16, C17, C18, C19,\n C20, C21, C22, C23, C24, C25, C26, C27, C28, C29,\n D0, D1, D2, D3, D4,\n]\n\n# Pass 1 warms specialization; pass 2 triggers JIT tracing.\nfor _ in range(2):\n for cls in ALL:\n cls().method()\n```\n\n\u003c/details>\n\n## Root cause\n\nCommit [`458aca9237`](https://github.com/python/cpython/commit/458aca92370d4b221f0e357f3104ed3c465756d6) added a `_GUARD_LOAD_SUPER_ATTR_METHOD` optimizer case in `Python/optimizer_bytecodes`.\n\nhttps://github.com/python/cpython/blob/70eb56be427aac3fc45342024dbcfef632accc3a/Python/optimizer_bytecodes.c#L1018-L1033\n\nWhen `known == NULL` but there are no `probable`, then `sym_set_const` is called with `(class_st, NULL)`.\n\n[sym_set_const](https://github.com/python/cpython/blob/70eb56be427aac3fc45342024dbcfef632accc3a/Python/optimizer_symbols.c#L476) calls [`make_const`](https://github.com/python/cpython/blob/70eb56be427aac3fc45342024dbcfef632accc3a/Python/optimizer_symbols.c#L181-L185), which then calls Py_NewRef(NULL) and finally will at some point try to increase the ref count:\n\nhttps://github.com/python/cpython/blob/70eb56be427aac3fc45342024dbcfef632accc3a/Include/refcount.h#L298\n \n## Fix\n\nI think that's enough to do the following check:\n\n```c\n// Python/optimizer_bytecodes.c, line ~955\nif (known != NULL) {\n sym_set_const(class_st, (PyObject *)known);\n}\n```\n\n_Found by compiling the stencils with ASAN_\n\n\u003cdetails>\n\u003csummary>Stack crash\u003c/summary>\n\n```bash\nAddressSanitizer:DEADLYSIGNAL\n=================================================================\n==418369==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x56043dbaecb7 bp 0x7fffe30dca20 sp 0x7fffe30dca20 T0)\n==418369==The signal is caused by a READ memory access.\n==418369==Hint: address points to the zero page.\n #0 0x56043dbaecb7 in Py_INCREF Include/refcount.h:286\n #1 0x56043dbaed00 in _Py_NewRef Include/refcount.h:536\n #2 0x56043dbaed00 in make_const Python/optimizer_symbols.c:187\n #3 0x56043dbb23b7 in _Py_uop_sym_set_const Python/optimizer_symbols.c:632\n #4 0x56043dba448f in optimize_uops Python/optimizer_cases.c.h:2371\n #5 0x56043dbaebd4 in _Py_uop_analyze_and_optimize Python/optimizer_analysis.c:792\n #6 0x56043db958e5 in uop_optimize Python/optimizer.c:1543\n #7 0x56043db96e45 in _PyOptimizer_Optimize Python/optimizer.c:166\n #8 0x56043d95308f in stop_tracing_and_jit Python/ceval.c:1138\n #9 0x56043d99c583 in _PyEval_EvalFrameDefault Python/generated_cases.c.h:12213\n #10 0x56043d9a03a2 in _PyEval_EvalFrame Include/internal/pycore_ceval.h:118\n #11 0x56043d9a06ed in _PyEval_Vector Python/ceval.c:2174\n #12 0x56043d9a097c in PyEval_EvalCode Python/ceval.c:686\n #13 0x56043dbde6de in run_eval_code_obj Python/pythonrun.c:1369\n #14 0x56043dbde9e7 in run_mod Python/pythonrun.c:1472\n #15 0x56043dbdf841 in pyrun_file Python/pythonrun.c:1296\n #16 0x56043dbe2424 in _PyRun_SimpleFileObject Python/pythonrun.c:518\n #17 0x56043dbe26ad in _PyRun_AnyFileObject Python/pythonrun.c:81\n #18 0x56043dc3582e in pymain_run_file_obj Modules/main.c:411\n #19 0x56043dc35a83 in pymain_run_file Modules/main.c:430\n #20 0x56043dc3730a in pymain_run_python Modules/main.c:715\n #21 0x56043dc3794c in Py_RunMain Modules/main.c:796\n #22 0x56043dc37b0b in pymain_main Modules/main.c:826\n #23 0x56043dc37e1c in Py_BytesMain Modules/main.c:850\n #24 0x56043d56eb71 in main Programs/python.c:15\n #25 0x7f159c345ca7 (/lib/x86_64-linux-gnu/libc.so.6+0x29ca7) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)\n #26 0x7f159c345d64 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29d64) (BuildId: 58749c528985eab03e6700ebc1469fa50aa41219)\n #27 0x56043d56eaa0 in _start (/home/.../python+0x326aa0) (BuildId: 0751f7a328fd60f87db90ff375974647e5b13d3a)\n\nAddressSanitizer can not provide additional info.\nSUMMARY: AddressSanitizer: SEGV Include/refcount.h:286 in Py_INCREF\n==418369==ABORTING\n```\n\n\u003c/summary>\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS","author":{"url":"https://github.com/DarkaMaul","@type":"Person","name":"DarkaMaul"},"datePublished":"2026-04-15T14:50:44Z","url":"https://github.com/python/cpython/issues/148618"}
| 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:fc69b6bc-c194-3469-f4c7-91ae33175961 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DCB0:EA09B:36C4C01:4896275:6B02078B |
| html-safe-nonce | a97b92e6020ee593f319545c488c65f34cd7a3b51d44357b9846f97fcdf7ad6a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEQ0IwOkVBMDlCOjM2QzRDMDE6NDg5NjI3NTo2QjAyMDc4QiIsInZpc2l0b3JfaWQiOiI1NDIzNDY1NjM0MDgyMTk1MzM5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 14c53fab229b9eccdee5997643ab2b1bd728772010a51366ec75bb72737df090 |
| hovercard-subject-tag | issue:4269754011 |
| 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/148618/issue_layout |
| twitter:image | https://opengraph.githubassets.com/19a4cdf1020c83e7fd246949a0b69efba55f86da99bc706dad283b536a4fceca/python/cpython/issues/148618 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/19a4cdf1020c83e7fd246949a0b69efba55f86da99bc706dad283b536a4fceca/python/cpython/issues/148618 |
| og:image:alt | Bug report Bug description: The JIT optimizer crashes with a NULL pointer dereference (SIGSEGV at address 0x8) when tracing a polymorphic super().method() call site that has been observed with mult... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DarkaMaul |
| 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