Title: Py_CLEAR/Py_SETREF() regression on the main branch with C++: SEGV with simple `numpy` program · Issue #157649 · python/cpython · GitHub
Open Graph Title: Py_CLEAR/Py_SETREF() regression on the main branch with C++: SEGV with simple `numpy` program · Issue #157649 · python/cpython
X Title: Py_CLEAR/Py_SETREF() regression on the main branch with C++: SEGV with simple `numpy` program · Issue #157649 · python/cpython
Description: Bug report Bug description: The program that triggers the crash: import numpy for _ in range(200): numpy.prod(2, dtype=numpy.intp) Reproducer at https://github.com/lucascolley/cpython-np-prod-repro. This produces the SEGV on CPython main...
Open Graph Description: Bug report Bug description: The program that triggers the crash: import numpy for _ in range(200): numpy.prod(2, dtype=numpy.intp) Reproducer at https://github.com/lucascolley/cpython-np-prod-repro...
X Description: Bug report Bug description: The program that triggers the crash: import numpy for _ in range(200): numpy.prod(2, dtype=numpy.intp) Reproducer at https://github.com/lucascolley/cpython-np-prod-repro...
Opengraph URL: https://github.com/python/cpython/issues/157649
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Py_CLEAR/Py_SETREF() regression on the main branch with C++: SEGV with simple `numpy` program","articleBody":"# Bug report\n\n### Bug description:\n\nThe program that triggers the crash:\n\n```python\nimport numpy\n\nfor _ in range(200):\n numpy.prod(2, dtype=numpy.intp)\n```\n\nReproducer at https://github.com/lucascolley/cpython-np-prod-repro. This produces the SEGV on CPython main branch, but passes on the 3.15 branch.\n\n```console\n❯ export BUILD_EDITABLE_PYTHON=false\n\n❯ pixi run repro\n✨ Pixi task (repro): python repro.py\nPython: 3.16.0a0 (heads/master-dirty:d8a1072491, Sep 16 2026, 22:19:03) [Clang 21.1.8 ]\nAddressSanitizer:DEADLYSIGNAL\n=================================================================\n==54023==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00010639c214 bp 0x00016afdf230 sp 0x00016afdf1d0 T0)\n==54023==The signal is caused by a WRITE memory access.\n==54023==HINT: address points to the zero page.\n #0 0x00010639c214 in _PyGCHead_SET_NEXT pycore_gc.h:151\n #1 0x00010639c214 in _PyObject_GC_UNTRACK pycore_gc.h:264\n #2 0x00010639c214 in type_dealloc typeobject.c:6898\n #3 0x000106338e40 in _Py_Dealloc object.c:3333\n #4 0x00010e880a34 in PyUFunc_GenericReduction+0x119c (_multiarray_umath.cpython-316-darwin.so:arm64+0x704a34)\n #5 0x000106237858 in _PyVectorcall_Call call.c:273\n #6 0x00010652b77c in _PyEval_EvalFrameDefault generated_cases.c.h:2831\n #7 0x0001065153bc in _PyEval_EvalFrame pycore_ceval.h:122\n #8 0x0001065153bc in _PyEval_Vector ceval.c:2176\n #9 0x000106237a78 in _PyObject_VectorcallTstate pycore_call.h:144\n #10 0x000106237a78 in PyObject_Vectorcall call.c:327\n #11 0x00010e54bd1c in dispatcher_vectorcall+0xc70 (_multiarray_umath.cpython-316-darwin.so:arm64+0x3cfd1c)\n #12 0x000106237a78 in _PyObject_VectorcallTstate pycore_call.h:144\n #13 0x000106237a78 in PyObject_Vectorcall call.c:327\n #14 0x000106515938 in _Py_VectorCall_StackRefSteal ceval.c:728\n #15 0x000106529170 in _PyEval_EvalFrameDefault generated_cases.c.h:3686\n #16 0x000106514db0 in _PyEval_EvalFrame pycore_ceval.h:122\n #17 0x000106514db0 in _PyEval_Vector ceval.c:2176\n #18 0x000106514db0 in PyEval_EvalCode ceval.c:681\n #19 0x00010665ba10 in run_mod pythonrun.c:1509\n #20 0x00010665633c in _PyRun_File pythonrun.c:1332\n #21 0x00010665633c in _PyRun_SimpleFile pythonrun.c:544\n #22 0x000106655998 in _PyRun_AnyFile pythonrun.c:92\n #23 0x0001066bd0b0 in pymain_run_file_obj main.c:478\n #24 0x0001066bd0b0 in pymain_run_file main.c:494\n #25 0x0001066bbe68 in pymain_run_python main.c:804\n #26 0x0001066bbe68 in Py_RunMain main.c:891\n #27 0x0001066bc830 in pymain_main main.c:921\n #28 0x0001066bc9e0 in Py_BytesMain main.c:945\n #29 0x000189febdfc in start+0x1b4c (dyld:arm64e+0x1fdfc)\n\n==54023==Register values:\n x[0] = 0x00006190000dde88 x[1] = 0x000000010639c054 x[2] = 0x000000016afde9d0 x[3] = 0x000061600009a870\n x[4] = 0x0000000000000218 x[5] = 0x0000000000000218 x[6] = 0x0000000169fe4000 x[7] = 0x0000000000000001\n x[8] = 0x00006190000dde80 x[9] = 0x0000000000000000 x[10] = 0x0000000000000000 x[11] = 0x00000fffffffffff\nx[12] = 0x0000000000000000 x[13] = 0xffffffffffffffff x[14] = 0x0000000000000000 x[15] = 0x00007fffffffffff\nx[16] = 0x0000000000000028 x[17] = 0x0000604000000410 x[18] = 0x0000000000000000 x[19] = 0x00006190000dde90\nx[20] = 0x0000604000000438 x[21] = 0x0000000080805980 x[22] = 0x0000008000020000 x[23] = 0x0000000106c42940\nx[24] = 0x0000008000020000 x[25] = 0x0000000000000000 x[26] = 0x000000016afdfb20 x[27] = 0x0000000000000000\nx[28] = 0x00006110001f42e4 fp = 0x000000016afdf230 lr = 0x000000010639c1d8 sp = 0x000000016afdf1d0\nAddressSanitizer can not provide additional info.\nSUMMARY: AddressSanitizer: SEGV pycore_gc.h:151 in _PyGCHead_SET_NEXT\n==54023==ABORTING\n```\n\n@ngoldbaum perhaps you can reproduce?\n\n```toml\n[workspace]\nchannels = [\"https://prefix.dev/conda-forge\"]\nplatforms = [\"osx-arm64\"]\npreview = [\"pixi-build\"]\nrequires-pixi = \">=0.74.0\"\n\n[tasks]\nrepro = \"python repro.py\"\n\n[dependencies]\nnumpy = {\n git = \"https://github.com/numpy/numpy\",\n package = {\n host-dependencies = {\n python = {\n flags = [\"asan\"],\n # passing with 3.15 branch\n # branch = \"3.15\",\n # failing with main\n branch = \"main\",\n git = \"https://github.com/python/cpython\",\n subdirectory = \"Tools/pixi-packages\",\n },\n meson-python = \"*\",\n cython = \"*\",\n },\n build = {\n backend.name = \"pixi-build-python\",\n config.compilers = [\"c\", \"cxx\"],\n },\n },\n}\n```\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-157718\n* gh-158070\n* gh-158176\n* gh-158227\n* gh-159143\n* gh-159264\n* gh-159276\n* gh-159296\n* gh-159314\n* gh-159371\n* gh-159374\n* gh-159375\n* gh-159378\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/lucascolley","@type":"Person","name":"lucascolley"},"datePublished":"2026-09-16T22:58:03Z","url":"https://github.com/python/cpython/issues/157649"}
| 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:4881d01b-94ed-ef0c-fbd8-89675bfe5e0e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A430:213839:3CFB836:4DDA7A4:6B020210 |
| html-safe-nonce | e20d321db2667e0d4af37baee583a23fd1d4a50c2c16df2ad8c9351c2d3d3949 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNDMwOjIxMzgzOTozQ0ZCODM2OjREREE3QTQ6NkIwMjAyMTAiLCJ2aXNpdG9yX2lkIjoiNzc5Nzg2NDY5MjIzMTMwNzc5MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 73fb98c93d22a38708650c1e84833586c16f821eee89a95c4539cb5cdad50bbb |
| hovercard-subject-tag | issue:5480786690 |
| 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/157649/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f01092cd800c6e73ac0da11559c7831909f4aee658505a9a3a0af47874d528d7/python/cpython/issues/157649 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f01092cd800c6e73ac0da11559c7831909f4aee658505a9a3a0af47874d528d7/python/cpython/issues/157649 |
| og:image:alt | Bug report Bug description: The program that triggers the crash: import numpy for _ in range(200): numpy.prod(2, dtype=numpy.intp) Reproducer at https://github.com/lucascolley/cpython-np-prod-repro... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lucascolley |
| 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