Title: test_threading.test_recursion_limit() does crash (segfault) on Alpine Linux (musl) · Issue #148260 · python/cpython · GitHub
Open Graph Title: test_threading.test_recursion_limit() does crash (segfault) on Alpine Linux (musl) · Issue #148260 · python/cpython
X Title: test_threading.test_recursion_limit() does crash (segfault) on Alpine Linux (musl) · Issue #148260 · python/cpython
Description: Python built with ./configure --with-pydebug --disable-gil and gcc -Og on Alpine Linux (Python built with musl C library). Example of crash on "AMD64 Alpine Linux NoGIL 3.x" buildbot: https://buildbot.python.org/#/builders/1819/builds/16...
Open Graph Description: Python built with ./configure --with-pydebug --disable-gil and gcc -Og on Alpine Linux (Python built with musl C library). Example of crash on "AMD64 Alpine Linux NoGIL 3.x" buildbot: https://build...
X Description: Python built with ./configure --with-pydebug --disable-gil and gcc -Og on Alpine Linux (Python built with musl C library). Example of crash on "AMD64 Alpine Linux NoGIL 3.x" buildbot: htt...
Opengraph URL: https://github.com/python/cpython/issues/148260
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"test_threading.test_recursion_limit() does crash (segfault) on Alpine Linux (musl)","articleBody":"Python built with `./configure --with-pydebug --disable-gil` and `gcc -Og` on Alpine Linux (Python built with `musl` C library).\n\nExample of crash on \"AMD64 Alpine Linux NoGIL 3.x\" buildbot: https://buildbot.python.org/#/builders/1819/builds/1699\n\nScript:\n\n```py\nimport threading\n\ndef recurse():\n return recurse()\n\ndef outer():\n try:\n recurse()\n except RecursionError:\n pass\n\nw = threading.Thread(target=outer)\nw.start()\nw.join()\nprint('end of main thread')\n```\n\ngdb traceback:\n\n```\n(gdb) where\n#0 0x0000560e9bedb871 in _Py_Dealloc (op=0x20004156010) at Objects/object.c:3277\n#1 0x0000560e9bedb9ef in _Py_MergeZeroLocalRefcount (op=op@entry=0x20004156010) at Objects/object.c:444\n#2 0x0000560e9c088aaf in Py_DECREF (filename=filename@entry=0x560e9c12425b \"./Include/refcount.h\", \n lineno=lineno@entry=520, op=0x20004156010) at ./Include/refcount.h:359\n#3 0x0000560e9c088af7 in Py_XDECREF (op=\u003coptimized out>) at ./Include/refcount.h:520\n#4 0x0000560e9c088e30 in tb_dealloc (op=0x20004156070) at Python/traceback.c:245\n#5 0x0000560e9bedb8e0 in _Py_Dealloc (op=0x20004156070) at Objects/object.c:3300\n#6 0x0000560e9bedb9ef in _Py_MergeZeroLocalRefcount (op=op@entry=0x20004156070) at Objects/object.c:444\n#7 0x0000560e9c088aaf in Py_DECREF (filename=filename@entry=0x560e9c12425b \"./Include/refcount.h\", \n lineno=lineno@entry=520, op=0x20004156070) at ./Include/refcount.h:359\n#8 0x0000560e9c088af7 in Py_XDECREF (op=\u003coptimized out>) at ./Include/refcount.h:520\n#9 0x0000560e9c088e30 in tb_dealloc (op=0x200041560d0) at Python/traceback.c:245\n#10 0x0000560e9bedb8e0 in _Py_Dealloc (op=0x200041560d0) at Objects/object.c:3300\n#11 0x0000560e9bedb9ef in _Py_MergeZeroLocalRefcount (op=op@entry=0x200041560d0) at Objects/object.c:444\n#12 0x0000560e9c088aaf in Py_DECREF (filename=filename@entry=0x560e9c12425b \"./Include/refcount.h\", \n lineno=lineno@entry=520, op=0x200041560d0) at ./Include/refcount.h:359\n#13 0x0000560e9c088af7 in Py_XDECREF (op=\u003coptimized out>) at ./Include/refcount.h:520\n#14 0x0000560e9c088e30 in tb_dealloc (op=0x20004156130) at Python/traceback.c:245\n#15 0x0000560e9bedb8e0 in _Py_Dealloc (op=0x20004156130) at Objects/object.c:3300\n#16 0x0000560e9bedb9ef in _Py_MergeZeroLocalRefcount (op=op@entry=0x20004156130) at Objects/object.c:444\n#17 0x0000560e9c088aaf in Py_DECREF (filename=filename@entry=0x560e9c12425b \"./Include/refcount.h\", \n lineno=lineno@entry=520, op=0x20004156130) at ./Include/refcount.h:359\n#18 0x0000560e9c088af7 in Py_XDECREF (op=\u003coptimized out>) at ./Include/refcount.h:520\n#19 0x0000560e9c088e30 in tb_dealloc (op=0x20004156190) at Python/traceback.c:245\n#20 0x0000560e9bedb8e0 in _Py_Dealloc (op=0x20004156190) at Objects/object.c:3300\n#21 0x0000560e9bedb9ef in _Py_MergeZeroLocalRefcount (op=op@entry=0x20004156190) at Objects/object.c:444\n#22 0x0000560e9c088aaf in Py_DECREF (filename=filename@entry=0x560e9c12425b \"./Include/refcount.h\", \n lineno=lineno@entry=520, op=0x20004156190) at ./Include/refcount.h:359\n#23 0x0000560e9c088af7 in Py_XDECREF (op=\u003coptimized out>) at ./Include/refcount.h:520\n#24 0x0000560e9c088e30 in tb_dealloc (op=0x200041561f0) at Python/traceback.c:245\n#25 0x0000560e9bedb8e0 in _Py_Dealloc (op=0x200041561f0) at Objects/object.c:3300\n#26 0x0000560e9bedb9ef in _Py_MergeZeroLocalRefcount (op=op@entry=0x200041561f0) at Objects/object.c:444\n#27 0x0000560e9c088aaf in Py_DECREF (filename=filename@entry=0x560e9c12425b \"./Include/refcount.h\", \n lineno=lineno@entry=520, op=0x200041561f0) at ./Include/refcount.h:359\n#28 0x0000560e9c088af7 in Py_XDECREF (op=\u003coptimized out>) at ./Include/refcount.h:520\n#29 0x0000560e9c088e30 in tb_dealloc (op=0x20004156250) at Python/traceback.c:245\n#30 0x0000560e9bedb8e0 in _Py_Dealloc (op=0x20004156250) at Objects/object.c:3300\n#31 0x0000560e9bedb9ef in _Py_MergeZeroLocalRefcount (op=op@entry=0x20004156250) at Objects/object.c:444\n#32 0x0000560e9c088aaf in Py_DECREF (filename=filename@entry=0x560e9c12425b \"./Include/refcount.h\", \n(...)\n#3751 0x0000560e9be774fb in PyObject_Call (callable=\u003coptimized out>, args=\u003coptimized out>, kwargs=\u003coptimized out>)\n at Objects/call.c:373\n#3752 0x0000560e9c10f6ef in thread_run (boot_raw=boot_raw@entry=0x20000030920) at ./Modules/_threadmodule.c:388\n#3753 0x0000560e9c0874c0 in pythread_wrapper (arg=\u003coptimized out>) at Python/thread_pthread.h:234\n#3754 0x00007f484b327573 in start (p=\u003coptimized out>) at src/thread/pthread_create.c:207\n#3755 0x00007f484b328ec1 in __clone () at src/thread/x86_64/clone.s:22\nBacktrace stopped: frame did not save the PC\n\n(gdb) info threads\n Id Target Id Frame \n 1 LWP 9804 \"python\" __cp_end () at src/thread/x86_64/syscall_cp.s:29\n* 2 LWP 9807 \"Thread-1 (outer\" 0x0000560e9bedb871 in _Py_Dealloc (op=0x20004156010) at Objects/object.c:3277\n```\n\n`_Py_Dealloc()` has the `Trashcan` mechanism which is supposed to avoid long chain of `_Py_Dealloc()` calls to reduce the stack memory consumption. But it seems like it doesn't work on Alpine Linux (Python built with `musl` C library).\n\ngdb variables in the `_Py_Dealloc()` frame:\n\n```\n(gdb) p type->tp_name\n$6 = 0x555ba66f5c7f \"traceback\"\n\n(gdb) p gc_flag\n$7 = 16384\n```\n\nIn the parent `_Py_Dealloc()` frame:\n\n```\n(gdb) p type->tp_name\n$9 = 0x555ba66f5c7f \"traceback\"\n(gdb) p gc_flag\n$10 = \u003coptimized out>\n(gdb) p margin\n$11 = 115\n```\n\nIn the first `_Py_Dealloc()` frame (outer):\n\n```\n(gdb) p margin\n$12 = 119\n(gdb) p type->tp_name\n$13 = 0x555ba66e9dcd \"RecursionError\"\n(gdb) p gc_flag\n$14 = \u003coptimized out>\n(gdb) p type->tp_flags & (1UL \u003c\u003c 14) # gc_flag\n$15 = 16384\n```\n\nOn a regular build (without Free Threading), the script works as expected, it displays:\n\n```\nend of main thread\n```\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-149993\n* gh-150150\n* gh-151586\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/vstinner","@type":"Person","name":"vstinner"},"datePublished":"2026-04-08T16:52:03Z","url":"https://github.com/python/cpython/issues/148260"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| 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:5d8fe9c3-d0d4-a4f2-a15f-5fa4f9a34539 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D01A:1F44B8:21ED8D:2F7D4E:6AECB631 |
| html-safe-nonce | 85bb79e5e2de812904459c5b7c5e6112fe2ff43045ac9e3be81292731b3639d2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMDFBOjFGNDRCODoyMUVEOEQ6MkY3RDRFOjZBRUNCNjMxIiwidmlzaXRvcl9pZCI6IjUyOTM5NTM5NjYxNzE1MzQ4OTciLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d976acaa7527fcd8563bc0128a3841df8afc6c210d37c7085a98a757cd22d5bf |
| hovercard-subject-tag | issue:4226169440 |
| 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/148260/issue_layout |
| twitter:image | https://opengraph.githubassets.com/110716c26e48ffd6e0f136936ccd91043267da84aaf28a05ce5e9317a6df2e8d/python/cpython/issues/148260 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/110716c26e48ffd6e0f136936ccd91043267da84aaf28a05ce5e9317a6df2e8d/python/cpython/issues/148260 |
| og:image:alt | Python built with ./configure --with-pydebug --disable-gil and gcc -Og on Alpine Linux (Python built with musl C library). Example of crash on "AMD64 Alpine Linux NoGIL 3.x" buildbot: https://build... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | vstinner |
| hostname | github.com |
| expected-hostname | github.com |
| None | 95ae5445dec4cded2bc4f9d97ede92b9116c0bf381a08a5c844b60b5bddcbc97 |
| 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 | db4ef601a7f034ae2a68e17d6eeaeb7ee9470192 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width