Title: JIT: Segfault in _Py_LazyJitTrampoline with ASan/UBSan enabled · Issue #139834 · python/cpython · GitHub
Open Graph Title: JIT: Segfault in _Py_LazyJitTrampoline with ASan/UBSan enabled · Issue #139834 · python/cpython
X Title: JIT: Segfault in _Py_LazyJitTrampoline with ASan/UBSan enabled · Issue #139834 · python/cpython
Description: Bug report Bug description: When CPython is built on the main branch with the experimental JIT, AddressSanitizer (ASan), and UndefinedBehaviorSanitizer (UBSan) enabled, it produces a segmentation fault. The crash is easily reproducible a...
Open Graph Description: Bug report Bug description: When CPython is built on the main branch with the experimental JIT, AddressSanitizer (ASan), and UndefinedBehaviorSanitizer (UBSan) enabled, it produces a segmentation f...
X Description: Bug report Bug description: When CPython is built on the main branch with the experimental JIT, AddressSanitizer (ASan), and UndefinedBehaviorSanitizer (UBSan) enabled, it produces a segmentation f...
Opengraph URL: https://github.com/python/cpython/issues/139834
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"JIT: Segfault in _Py_LazyJitTrampoline with ASan/UBSan enabled","articleBody":"# Bug report\n\n### Bug description:\n\nWhen CPython is built on the `main` branch with the experimental JIT, AddressSanitizer (ASan), and UndefinedBehaviorSanitizer (UBSan) enabled, it produces a segmentation fault.\n\nThe crash is easily reproducible and appears to be triggered by operations that use the `inspect` module, such as Tab autocompletion in the REPL.\n\nThe full crash log shows that before the final `SEGV` in `_Py_LazyJitTrampoline`, UBSan reports several runtime errors related to **misaligned memory stores and loads** within `Python/jit.c`. This suggests that incorrect memory access is the root cause of the crash.\n\nThe final error reported by AddressSanitizer is:\n`==...==ERROR: AddressSanitizer: SEGV on unknown address ... in _Py_LazyJitTrampoline`\n\nThis indicates a read from an invalid memory address, likely due to a corrupted pointer from the earlier misaligned access.\n\n### **Steps to Reproduce**\n\n1. **Build CPython** from the `main` branch using the following configuration script:\n\n ```bash\n #!/bin/bash\n set -e\n \n BUILD_DIR=\"build/debug\"\n \n echo \"--- Configuring and building in $BUILD_DIR ---\"\n mkdir -p \"$BUILD_DIR\"\n cd \"$BUILD_DIR\"\n \n CC=clang CXX=clang++ ../../configure --with-pydebug \\\n --with-address-sanitizer \\\n --with-undefined-behavior-sanitizer \\\n --enable-experimental-jit\n \n make -j$(nproc)\n \n echo \"--- Build complete in $BUILD_DIR. Executable: $PWD/python ---\"\n cd ../..\n ```\n\n2. **Start the REPL** using the newly built executable:\n ```bash\n ./build/debug/python\n ```\n\n3. **Trigger the crash**: In the Python REPL, type `import ins` (without hitting Enter) and then press the **Tab key** for autocompletion.\n\n4. The REPL will immediately crash with a segmentation fault.\n\n*(Note: Running the test suite with `python -m test` also fails with similar errors.)*\n\n### **Full Crash Log (with UBSan and ASan)**\n\n\u003cdetails>\n\u003csummary>Direct interpreter crash (with clang 18)\u003c/summary>\n\n```console\nPython 3.15.0a0 (heads/main:8b9606a2c57, Oct 9 2025, 12:17:36) [Clang 18.1.8 ] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\nPython/jit.c:228:5: runtime error: store to misaligned address 0x7f699e5aa5d4 for type 'uint64_t' (aka 'unsigned long'), which requires 8 byte alignment\n0x7f699e5aa5d4: note: pointer points here\n 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n ^\nSUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/jit.c:228:5\nPython/jit.c:396:24: runtime error: load of misaligned address 0x7f699e5aa5d4 for type 'uint64_t' (aka 'unsigned long'), which requires 8 byte alignment\n0x7f699e5aa5d4: note: pointer points here\n 00 00 00 00 98 08 47 59 20 56 00 00 f8 8a db 58 20 56 00 00 ae bc 22 9e 69 7f 00 00 00 00 00 00\n ^\nSUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/jit.c:396:24\nPython/jit.c:220:5: runtime error: store to misaligned address 0x7f699e5aa0d5 for type 'uint32_t' (aka 'unsigned int'), which requires 4 byte alignment\n0x7f699e5aa0d5: note: pointer points here\n 89 e6 ff 15 00 00 00 00 4c 8b 7b 40 4d 85 ff 0f 84 c0 01 00 00 48 c7 43 40 00 00 00 00 85 c0 0f\n ^\nSUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/jit.c:220:5\nAddressSanitizer:DEADLYSIGNAL\n=================================================================\n==18131==ERROR: AddressSanitizer: SEGV on unknown address 0x7f699da01ff8 (pc 0x56205944cf37 bp 0x7ffea7292d10 sp 0x7ffea7290720 T0)\n==18131==The signal is caused by a READ memory access.\n #0 0x56205944cf37 in _Py_LazyJitTrampoline /[...]/cpython/Python/jit.c:624:12\n #1 0x5620591269bd in _PyEval_EvalFrameDefault /[...]/cpython/Python/generated_cases.c.h:7671:25\n #2 0x5620590e1791 in _PyEval_Vector /[...]/cpython/Python/ceval.c:2001:12\n #3 0x5620595d9cdf in _PyObject_VectorcallTstate /[...]/cpython/./Include/internal/pycore_call.h:169:11\n #4 0x5620595d9cdf in _PyObject_CallNoArgs /[...]/cpython/./Include/internal/pycore_call.h:185:12\n #5 0x5620595d9cdf in pymain_run_interactive_hook /[...]/cpython/Modules/main.c:512:24\n #6 0x5620595d9459 in pymain_run_stdin /[...]/cpython/Modules/main.c:550:13\n #7 0x5620595d7215 in pymain_run_python /[...]/cpython/Modules/main.c:694:21\n #8 0x5620595d7215 in Py_RunMain /[...]/cpython/Modules/main.c:772:5\n #9 0x5620595d8168 in pymain_main /[...]/cpython/Modules/main.c:802:12\n #10 0x5620595d83db in Py_BytesMain /[...]/cpython/Modules/main.c:826:12\n #11 0x7f699e21e24c in __libc_start_main (/lib64/libc.so.6+0x3524c) (BuildId: 74f77bf013a66413c77197c121955e029c32d259)\n #12 0x5620587d3759 in _start /home/abuild/rpmbuild/BUILD/glibc-2.31/csu/../sysdeps/x86_64/start.S:120\n\nAddressSanitizer can not provide additional info.\nSUMMARY: AddressSanitizer: SEGV /[...]/cpython/Python/jit.c:624:12 in _Py_LazyJitTrampoline\n==18131==ABORTING\n```\n\u003c/details>\n\n\u003cdetails>\n\u003csummary>Click to expand the full crash log\u003c/summary>\n\n```console\n➜ main git:(gh-139269) ./build/debug_main/python\nPython 3.15.0a0 (heads/main-dirty:d2deb8fdef, Oct 9 2025, 12:40:31) [Clang 20.1.2 (0ubuntu1)] on linux\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n>>> import ins\n../../Python/jit.c:228:5: runtime error: store to misaligned address 0x7b33f8e275ab for type 'uint64_t' (aka 'unsigned long'), which requires 8 byte alignment\n0x7b33f8e275ab: note: pointer points here\n 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\n ^\nSUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../Python/jit.c:228:5\n\n../../Python/jit.c:396:24: runtime error: load of misaligned address 0x7b33f8e275ab for type 'uint64_t' (aka 'unsigned long'), which requires 8 byte alignment\n0x7b33f8e275ab: note: pointer points here\n 00 00 00 00 48 b0 75 7d bd 55 00 00 58 11 0a 7d\n bd 55 00 00 d0 bd c3 f8 33 7b 00 00 00 00 00 00\n ^\nSUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../Python/jit.c:396:24\n\n../../Python/jit.c:220:5: runtime error: store to misaligned address 0x7b33f8e270ca for type 'uint32_t' (aka 'unsigned int'), which requires 4 byte alignment\n0x7b33f8e270ca: note: pointer points here\n 89 de ff 15 00 00 00 00 4d 8b 6c 24 40 4d 85 ed\n 0f 84 a1 01 00 00 49 c7 44 24 40 00 00 00 00 85\n ^\nSUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../../Python/jit.c:220:5\n\nAddressSanitizer:DEADLYSIGNAL\n=================================================================\n==212839==ERROR: AddressSanitizer: SEGV on unknown address 0x7b33f8e21ff8 (pc 0x55bd7d737ab7 bp 0x7ffcb5aacf70 sp 0x7ffcb5aaa980 T0)\n==212839==The signal is caused by a READ memory access.\n #0 0x55bd7d737ab7 in _Py_LazyJitTrampoline /home/shamil/oss/cpython/main/build/debug_main/../../Python/jit.c:624:12\n #1 0x55bd7d40e524 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/build/debug_main/../../Python/generated_cases.c.h:7671:25\n #2 0x55bd7cf8f963 in _PyEval_EvalFrame /home/shamil/oss/cpython/main/build/debug_main/../../Include/internal/pycore_ceval.h:121:16\n #3 0x55bd7cf8f963 in gen_send_ex2 /home/shamil/oss/cpython/main/build/debug_main/../../Objects/genobject.c:259:24\n #4 0x55bd7cf87de0 in gen_iternext /home/shamil/oss/cpython/main/build/debug_main/../../Objects/genobject.c:634:9\n #5 0x55bd7d495670 in _PyForIter_VirtualIteratorNext /home/shamil/oss/cpython/main/build/debug_main/../../Python/ceval.c:3587:24\n #6 0x55bd7d40ba64 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/build/debug_main/../../Python/generated_cases.c.h:5649:36\n #7 0x55bd7cf8f963 in _PyEval_EvalFrame /home/shamil/oss/cpython/main/build/debug_main/../../Include/internal/pycore_ceval.h:121:16\n #8 0x55bd7cf8f963 in gen_send_ex2 /home/shamil/oss/cpython/main/build/debug_main/../../Objects/genobject.c:259:24\n #9 0x55bd7cf87de0 in gen_iternext /home/shamil/oss/cpython/main/build/debug_main/../../Objects/genobject.c:634:9\n #10 0x55bd7cfe844a in list_extend_iter_lock_held /home/shamil/oss/cpython/main/build/debug_main/../../Objects/listobject.c:1263:26\n #11 0x55bd7cfde7f5 in _list_extend /home/shamil/oss/cpython/main/build/debug_main/../../Objects/listobject.c:1452:15\n #12 0x55bd7cff4b1d in list___init___impl /home/shamil/oss/cpython/main/build/debug_main/../../Objects/listobject.c:3496:13\n #13 0x55bd7cfe4cf9 in list_vectorcall /home/shamil/oss/cpython/main/build/debug_main/../../Objects/listobject.c:3520:13\n #14 0x55bd7cf04e8e in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/build/debug_main/../../Include/internal/pycore_call.h:169:11\n #15 0x55bd7d41e0c7 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/build/debug_main/../../Python/generated_cases.c.h:1620:35\n #16 0x55bd7d3c99a1 in _PyEval_Vector /home/shamil/oss/cpython/main/build/debug_main/../../Python/ceval.c:2001:12\n #17 0x55bd7cf08361 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/build/debug_main/../../Include/internal/pycore_call.h:169:11\n #18 0x55bd7cf08361 in PyObject_CallOneArg /home/shamil/oss/cpython/main/build/debug_main/../../Objects/call.c:395:12\n #19 0x55bd7cf4b585 in property_descr_get /home/shamil/oss/cpython/main/build/debug_main/../../Objects/descrobject.c:1696:12\n #20 0x55bd7d0aafb0 in _PyObject_GenericGetAttrWithDict /home/shamil/oss/cpython/main/build/debug_main/../../Objects/object.c:1837:19\n #21 0x55bd7d0a8e86 in PyObject_GetAttr /home/shamil/oss/cpython/main/build/debug_main/../../Objects/object.c:1313:18\n #22 0x55bd7d41277c in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/build/debug_main/../../Python/generated_cases.c.h:7865:40\n #23 0x55bd7d3c99a1 in _PyEval_Vector /home/shamil/oss/cpython/main/build/debug_main/../../Python/ceval.c:2001:12\n #24 0x55bd7cf15183 in _PyObject_VectorcallTstate /home/shamil/oss/cpython/main/build/debug_main/../../Include/internal/pycore_call.h:169:11\n #25 0x55bd7cf114fd in method_vectorcall /home/shamil/oss/cpython/main/build/debug_main/../../Objects/classobject.c:95:18\n #26 0x55bd7cf07a4b in _PyVectorcall_Call /home/shamil/oss/cpython/main/build/debug_main/../../Objects/call.c:273:16\n #27 0x55bd7d3fb088 in _PyEval_EvalFrameDefault /home/shamil/oss/cpython/main/build/debug_main/../../Python/generated_cases.c.h:2616:32\n #28 0x55bd7d3c99a1 in _PyEval_Vector /home/shamil/oss/cpython/main/build/debug_main/../../Python/ceval.c:2001:12\n #29 0x55bd7cf078fb in _PyVectorcall_Call /home/shamil/oss/cpython/main/build/debug_main/../../Objects/call.c:285:24\n #30 0x55bd7d8d85ac in pymain_start_pyrepl /home/shamil/oss/cpython/main/build/debug_main/../../Modules/main.c:310:26\n #31 0x55bd7d8d771b in pymain_run_stdin /home/shamil/oss/cpython/main/build/debug_main/../../Modules/main.c:570:12\n #32 0x55bd7d8d53a1 in pymain_run_python /home/shamil/oss/cpython/main/build/debug_main/../../Modules/main.c:694:21\n #33 0x55bd7d8d53a1 in Py_RunMain /home/shamil/oss/cpython/main/build/debug_main/../../Modules/main.c:772:5\n #34 0x55bd7d8d62c1 in pymain_main /home/shamil/oss/cpython/main/build/debug_main/../../Modules/main.c:802:12\n #35 0x55bd7d8d652b in Py_BytesMain /home/shamil/oss/cpython/main/build/debug_main/../../Modules/main.c:826:12\n #36 0x7b33f8c2a577 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16\n #37 0x7b33f8c2a63a in __libc_start_main csu/../csu/libc-start.c:360:3\n #38 0x55bd7ca937d4 in _start (/home/shamil/oss/cpython/main/build/debug_main/python+0x96b7d4) (BuildId: e4e153f9517a81a1b32dbd4f646b3bf2a95714f3)\n\n==212839==Register values:\nrax = 0x00007b33f8e22000 rbx = 0x000079c3f7fe5be8 rcx = 0x0000000000000000 rdx = 0x0000000000000005\nrdi = 0x00007b33f8e22000 rsi = 0x0000000000001000 rbp = 0x00007ffcb5aacf70 rsp = 0x00007ffcb5aaa980\nr8 = 0x00000f667f1c4400 r9 = 0x00007b33f8e2201e r10 = 0x00000f667f1c4403 r11 = 0x0000000000000202\nr12 = 0x000055bd7e72e1a0 r13 = 0x000079c3f7fe5c80 r14 = 0x00000ab7afc6975c r15 = 0x000055bd7e34bae0\n\nAddressSanitizer can not provide additional info.\nSUMMARY: AddressSanitizer: SEGV /home/shamil/oss/cpython/main/build/debug_main/../../Python/jit.c:624:12 in _Py_LazyJitTrampoline\n==212839==ABORTING\n% ➜ main git:(gh-139269)\n```\n\u003c/details>\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux","author":{"url":"https://github.com/ashm-dev","@type":"Person","name":"ashm-dev"},"datePublished":"2025-10-09T10:06:03Z","url":"https://github.com/python/cpython/issues/139834"}
| 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:f7ed08d1-f37a-c1d4-6902-26a859a80ee3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C51C:1DC4CC:256EF71:317B2BC:6B02661C |
| html-safe-nonce | 3ed15f70a3f26d6d06303e39aea6f33a4592cd90b43a5b671d8f26ec6a7dc421 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTFDOjFEQzRDQzoyNTZFRjcxOjMxN0IyQkM6NkIwMjY2MUMiLCJ2aXNpdG9yX2lkIjoiNjIyNjE1MTgxMDAzODY1NDQ5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 35f99af74f629daec470a2c657c5161dd2b0399826048a0c9d7914adc85f7bc8 |
| hovercard-subject-tag | issue:3498491793 |
| 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/139834/issue_layout |
| twitter:image | https://opengraph.githubassets.com/558eb501da633b2852d4a7aa691d8d987933cbd3df77aece9d39e6d48c44252d/python/cpython/issues/139834 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/558eb501da633b2852d4a7aa691d8d987933cbd3df77aece9d39e6d48c44252d/python/cpython/issues/139834 |
| og:image:alt | Bug report Bug description: When CPython is built on the main branch with the experimental JIT, AddressSanitizer (ASan), and UndefinedBehaviorSanitizer (UBSan) enabled, it produces a segmentation f... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ashm-dev |
| 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