Title: test_capi fails with HWASan · Issue #149165 · python/cpython · GitHub
Open Graph Title: test_capi fails with HWASan · Issue #149165 · python/cpython
X Title: test_capi fails with HWASan · Issue #149165 · python/cpython
Description: Bug report Bug description: For bookkeeping, as requested in the contributing guide, but I intend to fix this myself. $ clang -v Debian clang version 19.1.7 (3~deb12u1) Target: aarch64-unknown-linux-gnu Thread model: posix InstalledDir: ...
Open Graph Description: Bug report Bug description: For bookkeeping, as requested in the contributing guide, but I intend to fix this myself. $ clang -v Debian clang version 19.1.7 (3~deb12u1) Target: aarch64-unknown-linu...
X Description: Bug report Bug description: For bookkeeping, as requested in the contributing guide, but I intend to fix this myself. $ clang -v Debian clang version 19.1.7 (3~deb12u1) Target: aarch64-unknown-linu...
Opengraph URL: https://github.com/python/cpython/issues/149165
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test_capi fails with HWASan","articleBody":"# Bug report\n\n### Bug description:\n\nFor bookkeeping, as requested in the contributing guide, but I intend to fix this myself.\n\n```\n$ clang -v\nDebian clang version 19.1.7 (3~deb12u1)\nTarget: aarch64-unknown-linux-gnu\nThread model: posix\nInstalledDir: /usr/lib/llvm-19/bin\nFound candidate GCC installation: /usr/lib/gcc/aarch64-linux-gnu/12\nSelected GCC installation: /usr/lib/gcc/aarch64-linux-gnu/12\nCandidate multilib: .;@m64\nSelected multilib: .;@m64\n$ export CFLAGS=\"-fsanitize=hwaddress -mllvm -hwasan-globals=0\"\n$ export LDFLAGS=\"-fsanitize=hwaddress -fuse-ld=lld -mllvm -hwasan-globals=0\"\n$ ./configure\n$ make -j6\n$ ./python -m test test_capi\nUsing random seed: 2977011291\n0:00:00 load avg: 0.08 Run 1 test sequentially in a single process\n0:00:00 load avg: 0.08 [1/1] test_capi\ntest test_capi failed -- Traceback (most recent call last):\n File \"/home/fmayer/cpython/Lib/test/test_capi/test_mem.py\", line 118, in test_pyobject_freed_is_freed\n self.check_pyobject_is_freed('check_pyobject_freed_is_freed')\n ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n File \"/home/fmayer/cpython/Lib/test/test_capi/test_mem.py\", line 102, in check_pyobject_is_freed\n assert_python_ok(\n ~~~~~~~~~~~~~~~~^\n '-c', code,\n ^^^^^^^^^^^\n PYTHONMALLOC=self.PYTHONMALLOC,\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n MALLOC_CONF=\"junk:false\",\n ^^^^^^^^^^^^^^^^^^^^^^^^^\n )\n ^\n File \"/home/fmayer/cpython/Lib/test/support/script_helper.py\", line 182, in assert_python_ok\n return _assert_python(True, *args, **env_vars)\n File \"/home/fmayer/cpython/Lib/test/support/script_helper.py\", line 167, in _assert_python\n res.fail(cmd_line)\n ~~~~~~~~^^^^^^^^^^\n File \"/home/fmayer/cpython/Lib/test/support/script_helper.py\", line 80, in fail\n raise AssertionError(f\"Process return code is {exitcode}\\n\"\n ...\u003c10 lines>...\n f\"---\")\nAssertionError: Process return code is 99\ncommand line: ['/home/fmayer/cpython/python', '-X', 'faulthandler', '-c', '\\nimport gc, os, sys, _testinternalcapi\\n# Disable the GC to avoid crash on GC collection\\ngc.disable()\\n_testinternalcapi.check_pyobject_freed_is_freed()\\n# Exit immediately to avoid a crash while deallocating\\n# the invalid object\\nos._exit(0)\\n']\n\nstdout:\n---\n\n---\n\nstderr:\n---\n==63098==ERROR: HWAddressSanitizer: tag-mismatch on address 0xec2dfffe0f10 at pc 0xffff87f39340\nREAD of size 4 at 0xec2dfffe0f10 tags: 30/f9 (ptr/mem) in thread T0\n #0 0xffff87f39340 in _Py_IsImmortal /home/fmayer/cpython/./Include/refcount.h:132:12\n #1 0xffff87f39340 in Py_SET_REFCNT /home/fmayer/cpython/./Include/refcount.h:166:9\n #2 0xffff87f39340 in check_pyobject_freed_is_freed /home/fmayer/cpython/./Modules/_testinternalcapi.c:1875:5\n #3 0xaaaad0ce7bec in _PyObject_VectorcallTstate /home/fmayer/cpython/./Include/internal/pycore_call.h:144:11\n #4 0xaaaad0ce7bec in PyObject_Vectorcall /home/fmayer/cpython/Objects/call.c:327:12\n #5 0xaaaad0ff03e8 in _Py_VectorCallInstrumentation_StackRefSteal /home/fmayer/cpython/Python/ceval.c:775:11\n #6 0xaaaad1010cd4 in _PyEval_EvalFrameDefault /home/fmayer/cpython/Python/generated_cases.c.h:1846:35\n #7 0xaaaad0fef39c in _PyEval_EvalFrame /home/fmayer/cpython/./Include/internal/pycore_ceval.h:118:16\n #8 0xaaaad0fef39c in _PyEval_Vector /home/fmayer/cpython/Python/ceval.c:2124:12\n #9 0xaaaad0fef39c in PyEval_EvalCode /home/fmayer/cpython/Python/ceval.c:686:21\n #10 0xaaaad113a07c in run_mod /home/fmayer/cpython/Python/pythonrun.c:1472:19\n #11 0xaaaad1136858 in _PyRun_StringFlagsWithName /home/fmayer/cpython/Python/pythonrun.c:1260:15\n #12 0xaaaad11364b4 in _PyRun_SimpleStringFlagsWithName /home/fmayer/cpython/Python/pythonrun.c:573:15\n #13 0xaaaad118f51c in pymain_run_command /home/fmayer/cpython/Modules/main.c:262:11\n #14 0xaaaad118f51c in pymain_run_python /home/fmayer/cpython/Modules/main.c:706:21\n #15 0xaaaad118f51c in Py_RunMain /home/fmayer/cpython/Modules/main.c:796:5\n #16 0xaaaad11902a0 in pymain_main /home/fmayer/cpython/Modules/main.c:826:12\n #17 0xaaaad1190384 in Py_BytesMain /home/fmayer/cpython/Modules/main.c:850:12\n #18 0xffff88727740 (/lib/aarch64-linux-gnu/libc.so.6+0x27740) (BuildId: 3ff3f95a1642952473d0d5739aaf308b0e24f694)\n #19 0xffff88727814 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x27814) (BuildId: 3ff3f95a1642952473d0d5739aaf308b0e24f694)\n #20 0xaaaad0bbc16c in _start (/home/fmayer/cpython/python+0x28c16c) (BuildId: c44e790f2cd3ba60)\n\n[0xec2dfffe0f00,0xec2dfffe0f30) is a small unallocated heap chunk; size: 48 offset: 16\n\nCause: use-after-free\n0xec2dfffe0f10 is located 16 bytes inside a 40-byte region [0xec2dfffe0f00,0xec2dfffe0f28)\nfreed by thread T0 here:\n #0 0xaaaad0bc3f90 in free (/home/fmayer/cpython/python+0x293f90) (BuildId: c44e790f2cd3ba60)\n #1 0xffff87f392b0 in check_pyobject_freed_is_freed /home/fmayer/cpython/./Modules/_testinternalcapi.c:1873:5\n #2 0xaaaad0ce7bec in _PyObject_VectorcallTstate /home/fmayer/cpython/./Include/internal/pycore_call.h:144:11\n #3 0xaaaad0ce7bec in PyObject_Vectorcall /home/fmayer/cpython/Objects/call.c:327:12\n #4 0xaaaad0ff03e8 in _Py_VectorCallInstrumentation_StackRefSteal /home/fmayer/cpython/Python/ceval.c:775:11\n #5 0xaaaad1010cd4 in _PyEval_EvalFrameDefault /home/fmayer/cpython/Python/generated_cases.c.h:1846:35\n #6 0xaaaad0fef39c in _PyEval_EvalFrame /home/fmayer/cpython/./Include/internal/pycore_ceval.h:118:16\n #7 0xaaaad0fef39c in _PyEval_Vector /home/fmayer/cpython/Python/ceval.c:2124:12\n #8 0xaaaad0fef39c in PyEval_EvalCode /home/fmayer/cpython/Python/ceval.c:686:21\n #9 0xaaaad113a07c in run_mod /home/fmayer/cpython/Python/pythonrun.c:1472:19\n #10 0xaaaad1136858 in _PyRun_StringFlagsWithName /home/fmayer/cpython/Python/pythonrun.c:1260:15\n #11 0xaaaad11364b4 in _PyRun_SimpleStringFlagsWithName /home/fmayer/cpython/Python/pythonrun.c:573:15\n #12 0xaaaad118f51c in pymain_run_command /home/fmayer/cpython/Modules/main.c:262:11\n #13 0xaaaad118f51c in pymain_run_python /home/fmayer/cpython/Modules/main.c:706:21\n #14 0xaaaad118f51c in Py_RunMain /home/fmayer/cpython/Modules/main.c:796:5\n #15 0xaaaad11902a0 in pymain_main /home/fmayer/cpython/Modules/main.c:826:12\n #16 0xaaaad1190384 in Py_BytesMain /home/fmayer/cpython/Modules/main.c:850:12\n #17 0xffff88727740 (/lib/aarch64-linux-gnu/libc.so.6+0x27740) (BuildId: 3ff3f95a1642952473d0d5739aaf308b0e24f694)\n #18 0xffff88727814 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x27814) (BuildId: 3ff3f95a1642952473d0d5739aaf308b0e24f694)\n #19 0xaaaad0bbc16c in _start (/home/fmayer/cpython/python+0x28c16c) (BuildId: c44e790f2cd3ba60)\n\npreviously allocated by thread T0 here:\n #0 0xaaaad0bc4608 in malloc (/home/fmayer/cpython/python+0x294608) (BuildId: c44e790f2cd3ba60)\n #1 0xaaaad0e17a58 in _PyMem_DebugRawAlloc /home/fmayer/cpython/Objects/obmalloc.c:3097:24\n #2 0xaaaad0e17a58 in _PyMem_DebugRawMalloc /home/fmayer/cpython/Objects/obmalloc.c:3130:12\n #3 0xaaaad0e17a58 in _PyMem_DebugMalloc /home/fmayer/cpython/Objects/obmalloc.c:3295:12\n #4 0xaaaad0e519e0 in _PyObject_MallocWithType /home/fmayer/cpython/./Include/internal/pycore_object_alloc.h:46:17\n #5 0xaaaad0e519e0 in _PyType_AllocNoTrack /home/fmayer/cpython/Objects/typeobject.c:2527:19\n #6 0xaaaad0e51674 in PyType_GenericAlloc /home/fmayer/cpython/Objects/typeobject.c:2558:21\n #7 0xaaaad0e5cb9c in type_call /home/fmayer/cpython/Objects/typeobject.c:2471:11\n #8 0xaaaad0ce69ec in _PyObject_MakeTpCall /home/fmayer/cpython/Objects/call.c:242:18\n #9 0xffff87f39260 in check_pyobject_freed_is_freed /home/fmayer/cpython/./Modules/_testinternalcapi.c:1869:20\n #10 0xaaaad0ce7bec in _PyObject_VectorcallTstate /home/fmayer/cpython/./Include/internal/pycore_call.h:144:11\n #11 0xaaaad0ce7bec in PyObject_Vectorcall /home/fmayer/cpython/Objects/call.c:327:12\n #12 0xaaaad0ff03e8 in _Py_VectorCallInstrumentation_StackRefSteal /home/fmayer/cpython/Python/ceval.c:775:11\n #13 0xaaaad1010cd4 in _PyEval_EvalFrameDefault /home/fmayer/cpython/Python/generated_cases.c.h:1846:35\n #14 0xaaaad0fef39c in _PyEval_EvalFrame /home/fmayer/cpython/./Include/internal/pycore_ceval.h:118:16\n #15 0xaaaad0fef39c in _PyEval_Vector /home/fmayer/cpython/Python/ceval.c:2124:12\n #16 0xaaaad0fef39c in PyEval_EvalCode /home/fmayer/cpython/Python/ceval.c:686:21\n #17 0xaaaad113a07c in run_mod /home/fmayer/cpython/Python/pythonrun.c:1472:19\n #18 0xaaaad1136858 in _PyRun_StringFlagsWithName /home/fmayer/cpython/Python/pythonrun.c:1260:15\n #19 0xaaaad11364b4 in _PyRun_SimpleStringFlagsWithName /home/fmayer/cpython/Python/pythonrun.c:573:15\n #20 0xaaaad118f51c in pymain_run_command /home/fmayer/cpython/Modules/main.c:262:11\n #21 0xaaaad118f51c in pymain_run_python /home/fmayer/cpython/Modules/main.c:706:21\n #22 0xaaaad118f51c in Py_RunMain /home/fmayer/cpython/Modules/main.c:796:5\n #23 0xaaaad11902a0 in pymain_main /home/fmayer/cpython/Modules/main.c:826:12\n #24 0xaaaad1190384 in Py_BytesMain /home/fmayer/cpython/Modules/main.c:850:12\n #25 0xffff88727740 (/lib/aarch64-linux-gnu/libc.so.6+0x27740) (BuildId: 3ff3f95a1642952473d0d5739aaf308b0e24f694)\n #26 0xffff88727814 in __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x27814) (BuildId: 3ff3f95a1642952473d0d5739aaf308b0e24f694)\n #27 0xaaaad0bbc16c in _start (/home/fmayer/cpython/python+0x28c16c) (BuildId: c44e790f2cd3ba60)\n\nhwasan_dev_note_heap_rb_distance: 1 1023\nhwasan_dev_note_num_matching_addrs: 0\nhwasan_dev_note_num_matching_addrs_4b: 0\nThread: T0 0xeffe00002000 stack: [0xffffd9146000,0xffffd9946000) sz: 8388608 tls: [0xffff88a02700,0xffff88a035c0)\n\n\nMemory tags around the buggy address (one tag corresponds to 16 bytes):\n 0xec2dfffe0700: a4 a4 70 70 04 93 93 0c 29 29 04 53 53 08 41 41 \n 0xec2dfffe0800: 0c 3d 3d 07 0a 0a 04 21 21 0b 46 46 0b c2 c2 0b \n 0xec2dfffe0900: 73 73 0b 55 55 03 f1 f1 05 f3 f3 0a 19 19 08 91 \n 0xec2dfffe0a00: 91 0c 24 24 07 b3 b3 0a 5e 5e 0a 6d 6d 09 77 77 \n 0xec2dfffe0b00: 0e 6d 6d 07 bd bd 0b 8a 8a 0b b1 b1 08 25 25 08 \n 0xec2dfffe0c00: dd dd 09 df df 08 95 95 08 25 25 25 d0 d0 0e a1 \n 0xec2dfffe0d00: a1 a1 0d 0d 07 7a 7a 08 a0 a0 08 93 93 08 c1 c1 \n 0xec2dfffe0e00: c1 0e 0e 0e 5d 5d 5d 74 74 74 95 95 95 7f 7f 7f \n=>0xec2dfffe0f00: f9 [f9] f9 00 00 00 00 00 00 00 00 00 00 00 00 00 \n 0xec2dfffe1000: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n 0xec2dfffe1100: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n 0xec2dfffe1200: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n 0xec2dfffe1300: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n 0xec2dfffe1400: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n 0xec2dfffe1500: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n 0xec2dfffe1600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \n 0xec2dfffe1700: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \nTags for short granules around the buggy address (one tag corresponds to 16 bytes):\n 0xec2dfffe0e00: .. fd 00 fd .. .. .. .. .. .. .. .. .. .. .. .. \n=>0xec2dfffe0f00: .. [..] .. .. .. .. .. .. .. .. .. .. .. .. .. .. \n 0xec2dfffe1000: .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. .. \nSee https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html#short-granules for a description of short granule tags\n\nRegisters where the failure occurred (pc 0xffff87f39340):\n x0 0000000000296af0 x1 0000effe0000fba8 x2 0000000000000003 x3 0000ec2dfffe0f00\n x4 0000000000000028 x5 0000000000000014 x6 0000ffffd9146000 x7 0000000000000001\n x8 0000000000000030 x9 00000ec2dfffe0f1 x10 00000000000000f9 x11 0000ffff889fc388\n x12 0000000000001b0c x13 0000000000000000 x14 0000000000000030 x15 00000000f6f6f6f6\n x16 0000aaaad0bd3a40 x17 0000000000000007 x18 9b00ec5e0006c0c8 x19 3000ec2dfffe0f10\n x20 0200efff00000000 x21 0000aaaad13d4a08 x22 0000000000000000 x23 8000000000000000\n x24 f600ffffd9943bb8 x25 0000000000000030 x26 fa00ed1dfffe89be x27 f600ffffd9943bb0\n x28 0000aaaad13d4a08 x29 0000ffffd9943ad0 x30 0000ffff87f39344 sp 0000ffffd9943ad0\nSUMMARY: HWAddressSanitizer: tag-mismatch /home/fmayer/cpython/./Include/refcount.h:132:12 in _Py_IsImmortal\n---\n\n0:00:12 load avg: 0.13 [1/1/1] test_capi failed (1 failure)\n```\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-149166\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/fmayer","@type":"Person","name":"fmayer"},"datePublished":"2026-04-30T00:25:47Z","url":"https://github.com/python/cpython/issues/149165"}
| 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:934b971a-8ccf-cb86-a1b2-05a9c02c6eae |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B53E:A950:DD7A2:1212A5:6B022CAF |
| html-safe-nonce | fb597c35909f9227d549bb89922782bdef9233c008eb068609ff7b23e96e9f2a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNTNFOkE5NTA6REQ3QTI6MTIxMkE1OjZCMDIyQ0FGIiwidmlzaXRvcl9pZCI6IjU1NTY2NzI2Nzg5NjgwNDQ3MTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | f5413c7c06e16b7f30bf833f7d87134e857001474ef67dce106ba0570b438b94 |
| hovercard-subject-tag | issue:4354492058 |
| 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/149165/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f0551d97859fbf2ccd074e5b4f83e599a5310dff61b8ef54905af727bd712227/python/cpython/issues/149165 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f0551d97859fbf2ccd074e5b4f83e599a5310dff61b8ef54905af727bd712227/python/cpython/issues/149165 |
| og:image:alt | Bug report Bug description: For bookkeeping, as requested in the contributing guide, but I intend to fix this myself. $ clang -v Debian clang version 19.1.7 (3~deb12u1) Target: aarch64-unknown-linu... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fmayer |
| 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