Title: TSAN failure with free-threaded build, test_daemon_threads_fatal_error · Issue #140138 · python/cpython · GitHub
Open Graph Title: TSAN failure with free-threaded build, test_daemon_threads_fatal_error · Issue #140138 · python/cpython
X Title: TSAN failure with free-threaded build, test_daemon_threads_fatal_error · Issue #140138 · python/cpython
Description: Bug report Bug description: It seems this unit test started failing after GH-140111. Build with the following configure options: ./configure --with-thread-sanitizer --with-pydebug --disable-gil. Command to trigger the failure (doesn't ha...
Open Graph Description: Bug report Bug description: It seems this unit test started failing after GH-140111. Build with the following configure options: ./configure --with-thread-sanitizer --with-pydebug --disable-gil. Co...
X Description: Bug report Bug description: It seems this unit test started failing after GH-140111. Build with the following configure options: ./configure --with-thread-sanitizer --with-pydebug --disable-gil. Co...
Opengraph URL: https://github.com/python/cpython/issues/140138
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TSAN failure with free-threaded build, test_daemon_threads_fatal_error","articleBody":"# Bug report\n\n### Bug description:\n\nIt seems this unit test started failing after GH-140111. Build with the following configure options: `./configure --with-thread-sanitizer --with-pydebug --disable-gil`.\n\nCommand to trigger the failure (doesn't happen every run). \n```\n./python -m test test_threading -m test_daemon_threads_fatal_error\n```\n\nThe console output from a failed run:\n```\n./python -m test test_threading -m test_daemon_threads_fatal_error\nUsing random seed: 3327068419\n0:00:00 load avg: 2.84 Run 1 test sequentially in a single process\n0:00:00 load avg: 2.84 [1/1] test_threading\ntest test_threading failed -- Traceback (most recent call last):\n File \"/home/nas/src/cpython/Lib/test/test_threading.py\", line 1801, in test_daemon_threads_fatal_error\n self._inner()\n ~~~~~~~~~~~^^\n File \"/home/nas/src/cpython/Lib/test/test_threading.py\", line 1796, in _inner\n assert_python_ok(\"-c\", script)\n ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^\n File \"/home/nas/src/cpython/Lib/test/support/script_helper.py\", line 182, in assert_python_ok\n return _assert_python(True, *args, **env_vars)\n File \"/home/nas/src/cpython/Lib/test/support/script_helper.py\", line 167, in _assert_python\n res.fail(cmd_line)\n ~~~~~~~~^^^^^^^^^^\n File \"/home/nas/src/cpython/Lib/test/support/script_helper.py\", line 80, in fail\n raise AssertionError(f\"Process return code is {exitcode}\\n\"\n ...\u003c10 lines\u003e...\n f\"---\")\nAssertionError: Process return code is 66\ncommand line: ['/home/nas/src/cpython/python', '-X', 'faulthandler', '-I', '-c', \"if 1:\\n import _testcapi\\n\\n _testcapi.run_in_subinterp('if 1:\\\\n import os\\\\n import threading\\\\n import time\\\\n\\\\n def f():\\\\n # Make sure the daemon thread is still running when\\\\n # Py_EndInterpreter is called.\\\\n time.sleep(30.0)\\\\n threading.Thread(target=f, daemon=True).start()\\\\n ')\\n \"]\n\nstdout:\n---\n\n---\n\nstderr:\n---\n==================\nWARNING: ThreadSanitizer: data race (pid=2411975)\n Write of size 8 at 0x7f082bd42050 by main thread:\n #0 memset ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:87 (libtsan.so.2+0x8412b) (BuildId: 4bf16ac194a27034832a03e77e518636fcad2b4e)\n #1 memset ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors_memintrinsics.inc:85 (libtsan.so.2+0x8412b)\n #2 fill_mem_debug Objects/obmalloc.c:2825 (python+0x2236e6) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #3 _PyMem_DebugRawFree Objects/obmalloc.c:2954 (python+0x223c17) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #4 PyMem_RawFree Objects/obmalloc.c:1023 (python+0x23eb48) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #5 free_interpreter Python/pystate.c:487 (python+0x4390e8) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #6 PyInterpreterState_Delete Python/pystate.c:965 (python+0x43bff6) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #7 finalize_interp_delete Python/pylifecycle.c:1963 (python+0x434511) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #8 Py_EndInterpreter Python/pylifecycle.c:2585 (python+0x436bb6) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #9 run_in_subinterp Modules/_testcapimodule.c:1224 (_testcapi.cpython-315td-x86_64-linux-gnu.so+0x1c63a) (BuildId: 4a8d5a43c74f1a1cbb285af9ec96499ca8113f97)\n #10 cfunction_call Objects/methodobject.c:575 (python+0x210755) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #11 _PyObject_MakeTpCall Objects/call.c:242 (python+0x189c96) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #12 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x189eff) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #13 PyObject_Vectorcall Objects/call.c:327 (python+0x189fb2) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #14 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1620 (python+0x35e501) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #15 _PyEval_EvalFrame Include/internal/pycore_ceval.h:121 (python+0x3909e1) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #16 _PyEval_Vector Python/ceval.c:2001 (python+0x390c3d) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #17 PyEval_EvalCode Python/ceval.c:884 (python+0x390d85) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #18 run_eval_code_obj Python/pythonrun.c:1365 (python+0x43fd2a) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #19 run_mod Python/pythonrun.c:1459 (python+0x43ffaf) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #20 _PyRun_StringFlagsWithName Python/pythonrun.c:1259 (python+0x440a78) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #21 _PyRun_SimpleStringFlagsWithName Python/pythonrun.c:578 (python+0x442b46) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #22 pymain_run_command Modules/main.c:261 (python+0x47a8aa) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #23 pymain_run_python Modules/main.c:682 (python+0x47b99c) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #24 Py_RunMain Modules/main.c:772 (python+0x47be56) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #25 pymain_main Modules/main.c:802 (python+0x47beea) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #26 Py_BytesMain Modules/main.c:826 (python+0x47bffb) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #27 main Programs/python.c:15 (python+0x97b87) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n\n Previous read of size 8 at 0x7f082bd42050 by thread T1:\n #0 drop_gil Python/ceval_gil.c:229 (python+0x3ea73c) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #1 _PyEval_ReleaseLock Python/ceval_gil.c:598 (python+0x3ebc38) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #2 detach_thread Python/pystate.c:2154 (python+0x43a264) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #3 _PyThreadState_Detach Python/pystate.c:2160 (python+0x43be92) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #4 PyEval_SaveThread Python/ceval_gil.c:642 (python+0x3ebe1b) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #5 pysleep Modules/timemodule.c:2255 (python+0x525e87) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #6 time_sleep Modules/timemodule.c:408 (python+0x525f93) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #7 cfunction_vectorcall_O Objects/methodobject.c:536 (python+0x20fbb5) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #8 _PyObject_VectorcallTstate Include/internal/pycore_call.h:169 (python+0x189e6c) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #9 PyObject_Vectorcall Objects/call.c:327 (python+0x189fb2) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #10 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1620 (python+0x35e501) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #11 _PyEval_EvalFrame Include/internal/pycore_ceval.h:121 (python+0x3909e1) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #12 _PyEval_Vector Python/ceval.c:2001 (python+0x390c3d) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #13 _PyFunction_Vectorcall Objects/call.c:413 (python+0x189a3e) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #14 _PyObject_VectorcallTstate Include/internal/pycore_call.h:169 (python+0x18df70) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #15 method_vectorcall Objects/classobject.c:73 (python+0x18e263) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #16 _PyObject_VectorcallTstate Include/internal/pycore_call.h:169 (python+0x3bafb7) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #17 context_run Python/context.c:728 (python+0x3bb0cf) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #18 method_vectorcall_FASTCALL_KEYWORDS Objects/descrobject.c:421 (python+0x1a1b1e) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #19 _PyObject_VectorcallTstate Include/internal/pycore_call.h:169 (python+0x189e6c) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #20 PyObject_Vectorcall Objects/call.c:327 (python+0x189fb2) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #21 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1620 (python+0x35e501) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #22 _PyEval_EvalFrame Include/internal/pycore_ceval.h:121 (python+0x3909e1) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #23 _PyEval_Vector Python/ceval.c:2001 (python+0x390c3d) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #24 _PyFunction_Vectorcall Objects/call.c:413 (python+0x189a3e) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #25 _PyObject_VectorcallTstate Include/internal/pycore_call.h:169 (python+0x18df70) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #26 method_vectorcall Objects/classobject.c:73 (python+0x18e263) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #27 _PyVectorcall_Call Objects/call.c:273 (python+0x18bc68) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #28 _PyObject_Call Objects/call.c:348 (python+0x18bfb1) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #29 PyObject_Call Objects/call.c:373 (python+0x18c011) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #30 thread_run Modules/_threadmodule.c:387 (python+0x522baa) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #31 pythread_wrapper Python/thread_pthread.h:234 (python+0x462551) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n\n Location is heap block of size 249119 at 0x7f082bd42000 allocated by main thread:\n #0 calloc ../../../../src/libsanitizer/tsan/tsan_interceptors_posix.cpp:698 (libtsan.so.2+0x827ef) (BuildId: 4bf16ac194a27034832a03e77e518636fcad2b4e)\n #1 _PyMem_RawCalloc Objects/obmalloc.c:77 (python+0x2208a4) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #2 _PyMem_DebugRawAlloc Objects/obmalloc.c:2884 (python+0x2237e7) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #3 _PyMem_DebugRawCalloc Objects/obmalloc.c:2929 (python+0x22397d) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #4 PyMem_RawCalloc Objects/obmalloc.c:1009 (python+0x23dd8a) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #5 alloc_interpreter Python/pystate.c:465 (python+0x438b70) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #6 _PyInterpreterState_New Python/pystate.c:663 (python+0x43a900) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #7 new_interpreter Python/pylifecycle.c:2425 (python+0x437433) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #8 Py_NewInterpreter Python/pylifecycle.c:2530 (python+0x437b2b) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #9 run_in_subinterp Modules/_testcapimodule.c:1214 (_testcapi.cpython-315td-x86_64-linux-gnu.so+0x1c611) (BuildId: 4a8d5a43c74f1a1cbb285af9ec96499ca8113f97)\n #10 cfunction_call Objects/methodobject.c:575 (python+0x210755) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #11 _PyObject_MakeTpCall Objects/call.c:242 (python+0x189c96) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #12 _PyObject_VectorcallTstate Include/internal/pycore_call.h:167 (python+0x189eff) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #13 PyObject_Vectorcall Objects/call.c:327 (python+0x189fb2) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #14 _PyEval_EvalFrameDefault Python/generated_cases.c.h:1620 (python+0x35e501) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #15 _PyEval_EvalFrame Include/internal/pycore_ceval.h:121 (python+0x3909e1) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #16 _PyEval_Vector Python/ceval.c:2001 (python+0x390c3d) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #17 PyEval_EvalCode Python/ceval.c:884 (python+0x390d85) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #18 run_eval_code_obj Python/pythonrun.c:1365 (python+0x43fd2a) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #19 run_mod Python/pythonrun.c:1459 (python+0x43ffaf) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #20 _PyRun_StringFlagsWithName Python/pythonrun.c:1259 (python+0x440a78) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #21 _PyRun_SimpleStringFlagsWithName Python/pythonrun.c:578 (python+0x442b46) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #22 pymain_run_command Modules/main.c:261 (python+0x47a8aa) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #23 pymain_run_python Modules/main.c:682 (python+0x47b99c) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #24 Py_RunMain Modules/main.c:772 (python+0x47be56) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #25 pymain_main Modules/main.c:802 (python+0x47beea) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #26 Py_BytesMain Modules/main.c:826 (python+0x47bffb) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n #27 main Programs/python.c:15 (python+0x97b87) (BuildId: d60894373dd47029a049d3cae6ed7d163f468e09)\n```\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 --\u003e\n### Linked PRs\n* gh-140224\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/nascheme","@type":"Person","name":"nascheme"},"datePublished":"2025-10-14T23:32:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":17},"url":"https://github.com/140138/cpython/issues/140138"}
| 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:913e34f1-bf9c-7475-f4ab-7ff8ec106136 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E6A6:28AE23:1E33D6A:2968F00:696ABD71 |
| html-safe-nonce | 8089493ccbdd7a1854d55c676c4d80fb4f338ff33e0e457260bb84ed0eb8759b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNkE2OjI4QUUyMzoxRTMzRDZBOjI5NjhGMDA6Njk2QUJENzEiLCJ2aXNpdG9yX2lkIjoiODkyMzQ1MDAwMTI4Mjc0MzY2NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 684c1f024e54a70ca9989bc7bae5ad019aa0a0f06775fba5d362d1123f47736a |
| hovercard-subject-tag | issue:3515835053 |
| 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/140138/issue_layout |
| twitter:image | https://opengraph.githubassets.com/70f88ad8a4a2d61099734f3be4e2762c8c7631f6364291368a8725fa539b9b04/python/cpython/issues/140138 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/70f88ad8a4a2d61099734f3be4e2762c8c7631f6364291368a8725fa539b9b04/python/cpython/issues/140138 |
| og:image:alt | Bug report Bug description: It seems this unit test started failing after GH-140111. Build with the following configure options: ./configure --with-thread-sanitizer --with-pydebug --disable-gil. Co... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | nascheme |
| hostname | github.com |
| expected-hostname | github.com |
| None | 46ce962e0e18113ea447391b6ace8b02d4d2861e57b4fbab3658698f73d8855b |
| 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 | 30300f30bb3949de255e84a146706a3bdb5c19c9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width