Title: memory leak in threading stack size · Issue #141044 · python/cpython · GitHub
Open Graph Title: memory leak in threading stack size · Issue #141044 · python/cpython
X Title: memory leak in threading stack size · Issue #141044 · python/cpython
Description: Bug report Bug description: import threading previous = threading.stack_size(127 * 1024) def worker(): pass t = threading.Thread(target=worker, name="worker-thread") t.start() threading.stack_size(0) LeakSanitizer output on main ========...
Open Graph Description: Bug report Bug description: import threading previous = threading.stack_size(127 * 1024) def worker(): pass t = threading.Thread(target=worker, name="worker-thread") t.start() threading.stack_size(...
X Description: Bug report Bug description: import threading previous = threading.stack_size(127 * 1024) def worker(): pass t = threading.Thread(target=worker, name="worker-thread") t.start() threading.s...
Opengraph URL: https://github.com/python/cpython/issues/141044
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"memory leak in threading stack size","articleBody":"# Bug report\n\n### Bug description:\n\n```python\nimport threading\nprevious = threading.stack_size(127 * 1024)\ndef worker():\n pass\nt = threading.Thread(target=worker, name=\"worker-thread\")\nt.start()\nthreading.stack_size(0)\n```\n\n\u003cdetails\u003e\n \u003csummary\u003eLeakSanitizer output on main\u003c/summary\u003e\n\n```\n=================================================================\n==3532388==ERROR: LeakSanitizer: detected memory leaks\n\nDirect leak of 88 byte(s) in 1 object(s) allocated from:\n #0 0x7e646db509c7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69\n #1 0x55cc45289c38 in _PyMem_RawMalloc ../Objects/obmalloc.c:63\n #2 0x55cc45289009 in _PyMem_DebugRawAlloc ../Objects/obmalloc.c:2887\n #3 0x55cc45289071 in _PyMem_DebugRawMalloc ../Objects/obmalloc.c:2920\n #4 0x55cc4528a8ef in _PyMem_DebugMalloc ../Objects/obmalloc.c:3085\n #5 0x55cc452b38dc in PyObject_Malloc ../Objects/obmalloc.c:1493\n #6 0x55cc454f3dd8 in _PyObject_MallocWithType ../Include/internal/pycore_object_alloc.h:46\n #7 0x55cc454f3dd8 in gc_alloc ../Python/gc.c:2344\n #8 0x55cc454f3f2e in _PyObject_GC_New ../Python/gc.c:2364\n #9 0x55cc451c9034 in PyMethod_New ../Objects/classobject.c:119\n #10 0x55cc452191a2 in cm_descr_get ../Objects/funcobject.c:1473\n #11 0x55cc452fdc1c in _Py_type_getattro_impl ../Objects/typeobject.c:6382\n #12 0x55cc452fde00 in _Py_type_getattro ../Objects/typeobject.c:6424\n #13 0x55cc45282b80 in PyObject_GetAttr ../Objects/object.c:1313\n #14 0x55cc45283dd3 in _PyObject_GetMethodStackRef ../Objects/object.c:1706\n #15 0x55cc45467d64 in _PyEval_EvalFrameDefault ../Python/generated_cases.c.h:7844\n #16 0x55cc45486105 in _PyEval_EvalFrame ../Include/internal/pycore_ceval.h:121\n #17 0x55cc454863f9 in _PyEval_Vector ../Python/ceval.c:2005\n #18 0x55cc451c12b7 in _PyFunction_Vectorcall ../Objects/call.c:413\n #19 0x55cc451c177e in _PyObject_VectorcallTstate ../Include/internal/pycore_call.h:169\n #20 0x55cc451c1c3c in _PyObject_CallFunctionVa ../Objects/call.c:552\n #21 0x55cc451c226d in callmethod ../Objects/call.c:626\n #22 0x55cc451c2472 in PyObject_CallMethod ../Objects/call.c:645\n #23 0x55cc45519b64 in init_importlib ../Python/import.c:3223\n #24 0x55cc4551ad12 in _PyImport_InitCore ../Python/import.c:4035\n #25 0x55cc45563be1 in pycore_interp_init ../Python/pylifecycle.c:942\n #26 0x55cc45563e06 in pyinit_config ../Python/pylifecycle.c:971\n #27 0x55cc455712e3 in pyinit_core ../Python/pylifecycle.c:1134\n #28 0x55cc4557153b in Py_InitializeFromConfig ../Python/pylifecycle.c:1454\n #29 0x55cc455d4c9e in pymain_init ../Modules/main.c:68\n #30 0x55cc455d50dc in pymain_main ../Modules/main.c:793\n\nIndirect leak of 96 byte(s) in 1 object(s) allocated from:\n #0 0x7e646db509c7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69\n #1 0x55cc45289c38 in _PyMem_RawMalloc ../Objects/obmalloc.c:63\n #2 0x55cc45289009 in _PyMem_DebugRawAlloc ../Objects/obmalloc.c:2887\n #3 0x55cc45289071 in _PyMem_DebugRawMalloc ../Objects/obmalloc.c:2920\n #4 0x55cc4528a8ef in _PyMem_DebugMalloc ../Objects/obmalloc.c:3085\n #5 0x55cc452b38dc in PyObject_Malloc ../Objects/obmalloc.c:1493\n #6 0x55cc454f3dd8 in _PyObject_MallocWithType ../Include/internal/pycore_object_alloc.h:46\n #7 0x55cc454f3dd8 in gc_alloc ../Python/gc.c:2344\n #8 0x55cc454f4037 in _PyObject_GC_NewVar ../Python/gc.c:2386\n #9 0x55cc452c9d82 in tuple_alloc ../Objects/tupleobject.c:57\n #10 0x55cc452cca50 in PyTuple_New ../Objects/tupleobject.c:81\n #11 0x55cc4554f81d in r_object ../Python/marshal.c:1372\n #12 0x55cc455504e9 in r_object ../Python/marshal.c:1560\n #13 0x55cc4554f9d8 in r_object ../Python/marshal.c:1378\n #14 0x55cc455504b9 in r_object ../Python/marshal.c:1554\n #15 0x55cc45551305 in read_object ../Python/marshal.c:1714\n #16 0x55cc45551558 in marshal_loads_impl ../Python/marshal.c:2059\n #17 0x55cc45551c95 in marshal_loads ../Python/clinic/marshal.c.h:344\n #18 0x55cc45446cfa in _PyEval_EvalFrameDefault ../Python/generated_cases.c.h:2361\n #19 0x55cc45486105 in _PyEval_EvalFrame ../Include/internal/pycore_ceval.h:121\n #20 0x55cc454863f9 in _PyEval_Vector ../Python/ceval.c:2005\n #21 0x55cc451c12b7 in _PyFunction_Vectorcall ../Objects/call.c:413\n #22 0x55cc451c177e in _PyObject_VectorcallTstate ../Include/internal/pycore_call.h:169\n #23 0x55cc451c34bf in object_vacall ../Objects/call.c:819\n #24 0x55cc451c373d in PyObject_CallMethodObjArgs ../Objects/call.c:886\n #25 0x55cc455133c5 in import_find_and_load ../Python/import.c:3688\n #26 0x55cc4551a2f5 in PyImport_ImportModuleLevelObject ../Python/import.c:3770\n #27 0x55cc454357c3 in _PyEval_ImportName ../Python/ceval.c:3025\n #28 0x55cc4545e461 in _PyEval_EvalFrameDefault ../Python/generated_cases.c.h:6219\n #29 0x55cc45486105 in _PyEval_EvalFrame ../Include/internal/pycore_ceval.h:121\n #30 0x55cc454863f9 in _PyEval_Vector ../Python/ceval.c:2005\n\nIndirect leak of 96 byte(s) in 1 object(s) allocated from:\n #0 0x7e646db509c7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69\n #1 0x55cc45289c38 in _PyMem_RawMalloc ../Objects/obmalloc.c:63\n #2 0x55cc45289009 in _PyMem_DebugRawAlloc ../Objects/obmalloc.c:2887\n #3 0x55cc45289071 in _PyMem_DebugRawMalloc ../Objects/obmalloc.c:2920\n #4 0x55cc4528a8ef in _PyMem_DebugMalloc ../Objects/obmalloc.c:3085\n #5 0x55cc452b38dc in PyObject_Malloc ../Objects/obmalloc.c:1493\n #6 0x55cc454f3dd8 in _PyObject_MallocWithType ../Include/internal/pycore_object_alloc.h:46\n #7 0x55cc454f3dd8 in gc_alloc ../Python/gc.c:2344\n #8 0x55cc454f3f2e in _PyObject_GC_New ../Python/gc.c:2364\n #9 0x55cc45276170 in PyCMethod_New ../Objects/methodobject.c:108\n #10 0x55cc451dea0b in method_get ../Objects/descrobject.c:158\n #11 0x55cc45284b2c in _PyObject_GenericGetAttrWithDict ../Objects/object.c:1893\n #12 0x55cc45285b28 in PyObject_GenericGetAttr ../Objects/object.c:1923\n #13 0x55cc45282b80 in PyObject_GetAttr ../Objects/object.c:1313\n #14 0x55cc45467f8a in _PyEval_EvalFrameDefault ../Python/generated_cases.c.h:7865\n #15 0x55cc45486105 in _PyEval_EvalFrame ../Include/internal/pycore_ceval.h:121\n #16 0x55cc454863f9 in _PyEval_Vector ../Python/ceval.c:2005\n #17 0x55cc451c12b7 in _PyFunction_Vectorcall ../Objects/call.c:413\n #18 0x55cc451c78c7 in _PyObject_VectorcallTstate ../Include/internal/pycore_call.h:169\n #19 0x55cc451c7d81 in method_vectorcall ../Objects/classobject.c:73\n #20 0x55cc451c4ad1 in _PyVectorcall_Call ../Objects/call.c:273\n #21 0x55cc451c50dd in _PyObject_Call ../Objects/call.c:348\n #22 0x55cc451c5123 in PyObject_Call ../Objects/call.c:373\n #23 0x55cc456d25b9 in thread_run ../Modules/_threadmodule.c:387\n #24 0x55cc455ade23 in pythread_wrapper ../Python/thread_pthread.h:234\n #25 0x7e646dab1a41 in asan_thread_start ../../../../src/libsanitizer/asan/asan_interceptors.cpp:234\n #26 0x7e646d7f4aa3 (/lib/x86_64-linux-gnu/libc.so.6+0x9caa3) (BuildId: 282c2c16e7b6600b0b22ea0c99010d2795752b5f)\n\nIndirect leak of 88 byte(s) in 1 object(s) allocated from:\n #0 0x7e646db509c7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69\n #1 0x55cc45289c38 in _PyMem_RawMalloc ../Objects/obmalloc.c:63\n #2 0x55cc45289009 in _PyMem_DebugRawAlloc ../Objects/obmalloc.c:2887\n #3 0x55cc45289071 in _PyMem_DebugRawMalloc ../Objects/obmalloc.c:2920\n #4 0x55cc4528a8ef in _PyMem_DebugMalloc ../Objects/obmalloc.c:3085\n #5 0x55cc452b38dc in PyObject_Malloc ../Objects/obmalloc.c:1493\n #6 0x55cc454f3dd8 in _PyObject_MallocWithType ../Include/internal/pycore_object_alloc.h:46\n #7 0x55cc454f3dd8 in gc_alloc ../Python/gc.c:2344\n #8 0x55cc454f3f2e in _PyObject_GC_New ../Python/gc.c:2364\n #9 0x55cc45250446 in new_dict ../Objects/dictobject.c:875\n #10 0x55cc45251b2f in PyDict_New ../Objects/dictobject.c:973\n #11 0x55cc45251b7e in dict_new_presized ../Objects/dictobject.c:2204\n #12 0x55cc45259e23 in _PyDict_FromItems ../Objects/dictobject.c:2245\n #13 0x55cc45440114 in _PyEval_EvalFrameDefault ../Python/generated_cases.c.h:1272\n #14 0x55cc45486105 in _PyEval_EvalFrame ../Include/internal/pycore_ceval.h:121\n #15 0x55cc454863f9 in _PyEval_Vector ../Python/ceval.c:2005\n #16 0x55cc451c12b7 in _PyFunction_Vectorcall ../Objects/call.c:413\n #17 0x55cc451c177e in _PyObject_VectorcallTstate ../Include/internal/pycore_call.h:169\n #18 0x55cc451c34bf in object_vacall ../Objects/call.c:819\n #19 0x55cc451c373d in PyObject_CallMethodObjArgs ../Objects/call.c:886\n #20 0x55cc455133c5 in import_find_and_load ../Python/import.c:3688\n #21 0x55cc4551a2f5 in PyImport_ImportModuleLevelObject ../Python/import.c:3770\n #22 0x55cc45426967 in builtin___import___impl ../Python/bltinmodule.c:285\n #23 0x55cc45426c32 in builtin___import__ ../Python/clinic/bltinmodule.c.h:110\n #24 0x55cc4527491b in cfunction_vectorcall_FASTCALL_KEYWORDS ../Objects/methodobject.c:465\n #25 0x55cc451c177e in _PyObject_VectorcallTstate ../Include/internal/pycore_call.h:169\n #26 0x55cc451c1c3c in _PyObject_CallFunctionVa ../Objects/call.c:552\n #27 0x55cc451c1e61 in PyObject_CallFunction ../Objects/call.c:574\n #28 0x55cc4551a8f4 in PyImport_Import ../Python/import.c:3962\n #29 0x55cc4551aa9f in PyImport_ImportModule ../Python/import.c:3410\n #30 0x55cc45564580 in init_import_site ../Python/pylifecycle.c:2741\n\nIndirect leak of 88 byte(s) in 1 object(s) allocated from:\n #0 0x7e646db509c7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69\n #1 0x55cc45289c38 in _PyMem_RawMalloc ../Objects/obmalloc.c:63\n #2 0x55cc45289009 in _PyMem_DebugRawAlloc ../Objects/obmalloc.c:2887\n #3 0x55cc45289071 in _PyMem_DebugRawMalloc ../Objects/obmalloc.c:2920\n #4 0x55cc4528a8ef in _PyMem_DebugMalloc ../Objects/obmalloc.c:3085\n #5 0x55cc452b38dc in PyObject_Malloc ../Objects/obmalloc.c:1493\n #6 0x55cc454f3dd8 in _PyObject_MallocWithType ../Include/internal/pycore_object_alloc.h:46\n #7 0x55cc454f3dd8 in gc_alloc ../Python/gc.c:2344\n #8 0x55cc454f3f2e in _PyObject_GC_New ../Python/gc.c:2364\n #9 0x55cc45250446 in new_dict ../Objects/dictobject.c:875\n #10 0x55cc45251b2f in PyDict_New ../Objects/dictobject.c:973\n #11 0x55cc4542fff5 in initialize_locals ../Python/ceval.c:1583\n #12 0x55cc45432fd4 in _PyEvalFramePushAndInit ../Python/ceval.c:1875\n #13 0x55cc454863cf in _PyEval_Vector ../Python/ceval.c:1995\n #14 0x55cc451c12b7 in _PyFunction_Vectorcall ../Objects/call.c:413\n #15 0x55cc451c4453 in _PyObject_VectorcallDictTstate ../Objects/call.c:135\n #16 0x55cc451c4878 in _PyObject_Call_Prepend ../Objects/call.c:504\n #17 0x55cc452dae55 in slot_tp_new ../Objects/typeobject.c:10874\n #18 0x55cc452e93f8 in type_call ../Objects/typeobject.c:2449\n #19 0x55cc451c1570 in _PyObject_MakeTpCall ../Objects/call.c:242\n #20 0x55cc451c4589 in _PyObject_VectorcallDictTstate ../Objects/call.c:130\n #21 0x55cc451c46ac in PyObject_VectorcallDict ../Objects/call.c:159\n #22 0x55cc45427cda in builtin___build_class__ ../Python/bltinmodule.c:213\n #23 0x55cc4527491b in cfunction_vectorcall_FASTCALL_KEYWORDS ../Objects/methodobject.c:465\n #24 0x55cc451c177e in _PyObject_VectorcallTstate ../Include/internal/pycore_call.h:169\n #25 0x55cc451c1871 in PyObject_Vectorcall ../Objects/call.c:327\n #26 0x55cc45449f11 in _PyEval_EvalFrameDefault ../Python/generated_cases.c.h:2920\n #27 0x55cc45486105 in _PyEval_EvalFrame ../Include/internal/pycore_ceval.h:121\n #28 0x55cc454863f9 in _PyEval_Vector ../Python/ceval.c:2005\n #29 0x55cc454866a9 in PyEval_EvalCode ../Python/ceval.c:888\n #30 0x55cc45424bcb in builtin_exec_impl ../Python/bltinmodule.c:1180\n\nIndirect leak of 88 byte(s) in 1 object(s) allocated from:\n #0 0x7e646db509c7 in malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:69\n #1 0x55cc45289c38 in _PyMem_RawMalloc ../Objects/obmalloc.c:63\n #2 0x55cc45289009 in _PyMem_DebugRawAlloc ../Objects/obmalloc.c:2887\n #3 0x55cc45289071 in _PyMem_DebugRawMalloc ../Objects/obmalloc.c:2920\n #4 0x55cc4528a8ef in _PyMem_DebugMalloc ../Objects/obmalloc.c:3085\n #5 0x55cc452b38dc in PyObject_Malloc ../Objects/obmalloc.c:1493\n #6 0x55cc454f3dd8 in _PyObject_MallocWithType ../Include/internal/pycore_object_alloc.h:46\n #7 0x55cc454f3dd8 in gc_alloc ../Python/gc.c:2344\n #8 0x55cc454f3f2e in _PyObject_GC_New ../Python/gc.c:2364\n #9 0x55cc451c9034 in PyMethod_New ../Objects/classobject.c:119\n #10 0x55cc452191a2 in cm_descr_get ../Objects/funcobject.c:1473\n #11 0x55cc452fdc1c in _Py_type_getattro_impl ../Objects/typeobject.c:6382\n #12 0x55cc452fde00 in _Py_type_getattro ../Objects/typeobject.c:6424\n #13 0x55cc45282b80 in PyObject_GetAttr ../Objects/object.c:1313\n #14 0x55cc45467f8a in _PyEval_EvalFrameDefault ../Python/generated_cases.c.h:7865\n #15 0x55cc45486105 in _PyEval_EvalFrame ../Include/internal/pycore_ceval.h:121\n #16 0x55cc454863f9 in _PyEval_Vector ../Python/ceval.c:2005\n #17 0x55cc451c12b7 in _PyFunction_Vectorcall ../Objects/call.c:413\n #18 0x55cc451c177e in _PyObject_VectorcallTstate ../Include/internal/pycore_call.h:169\n #19 0x55cc451c34bf in object_vacall ../Objects/call.c:819\n #20 0x55cc451c373d in PyObject_CallMethodObjArgs ../Objects/call.c:886\n #21 0x55cc455133c5 in import_find_and_load ../Python/import.c:3688\n #22 0x55cc4551a2f5 in PyImport_ImportModuleLevelObject ../Python/import.c:3770\n #23 0x55cc454357c3 in _PyEval_ImportName ../Python/ceval.c:3025\n #24 0x55cc4545e461 in _PyEval_EvalFrameDefault ../Python/generated_cases.c.h:6219\n #25 0x55cc45486105 in _PyEval_EvalFrame ../Include/internal/pycore_ceval.h:121\n #26 0x55cc454863f9 in _PyEval_Vector ../Python/ceval.c:2005\n #27 0x55cc451c12b7 in _PyFunction_Vectorcall ../Objects/call.c:413\n #28 0x55cc451c177e in _PyObject_VectorcallTstate ../Include/internal/pycore_call.h:169\n #29 0x55cc451c1ae5 in _PyObject_CallNoArgsTstate ../Include/internal/pycore_call.h:176\n #30 0x55cc451c1ae5 in _PyObject_CallFunctionVa ../Objects/call.c:531\n #31 0x55cc451c226d in callmethod ../Objects/call.c:626\n\nSUMMARY: AddressSanitizer: 544 byte(s) leaked in 6 allocation(s).\n```\n\n\u003c/details\u003e\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux","author":{"url":"https://github.com/YuanchengJiang","@type":"Person","name":"YuanchengJiang"},"datePublished":"2025-11-05T10:31:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/141044/cpython/issues/141044"}
| 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:3ab464bc-36c7-d90e-86e4-3aaf6790c6af |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B9B4:2D0DCE:102488A:1592D0F:696992A9 |
| html-safe-nonce | dcd7d8f2af4d7e4d719e8bd19511bf02fac81d73219d82f24405a8b9813768c1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOUI0OjJEMERDRToxMDI0ODhBOjE1OTJEMEY6Njk2OTkyQTkiLCJ2aXNpdG9yX2lkIjoiOTg1ODk5NjA4NDQyNTA3OTQ2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 85793bea0f28cc946979697310d8623ef65cc97825ae2b09d178b25ed148dd39 |
| hovercard-subject-tag | issue:3590337921 |
| 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/141044/issue_layout |
| twitter:image | https://opengraph.githubassets.com/faf47a90f794677fcc79e8d6afc25701613a7f9046955f4357398e672e8cf592/python/cpython/issues/141044 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/faf47a90f794677fcc79e8d6afc25701613a7f9046955f4357398e672e8cf592/python/cpython/issues/141044 |
| og:image:alt | Bug report Bug description: import threading previous = threading.stack_size(127 * 1024) def worker(): pass t = threading.Thread(target=worker, name="worker-thread") t.start() threading.stack_size(... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | YuanchengJiang |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3542e147982176a7ebaa23dfb559c8af16f721c03ec560c68c56b64a0f35e751 |
| 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 | af80af7cc9e3de9c336f18b208a600950a3c187c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width