Title: TSAN alarm in `dictobject.c` while using `setattr` · Issue #144774 · python/cpython · GitHub
Open Graph Title: TSAN alarm in `dictobject.c` while using `setattr` · Issue #144774 · python/cpython
X Title: TSAN alarm in `dictobject.c` while using `setattr` · Issue #144774 · python/cpython
Description: Bug report Bug description: While working around with my previous issue, I found another TSAN alarm. from threading import Thread import random import copy E = Exception() def test1(): for _ in range(100): setattr(E, 'x', random.randint(...
Open Graph Description: Bug report Bug description: While working around with my previous issue, I found another TSAN alarm. from threading import Thread import random import copy E = Exception() def test1(): for _ in ran...
X Description: Bug report Bug description: While working around with my previous issue, I found another TSAN alarm. from threading import Thread import random import copy E = Exception() def test1(): for _ in ran...
Opengraph URL: https://github.com/python/cpython/issues/144774
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TSAN alarm in `dictobject.c` while using `setattr`","articleBody":"# Bug report\n\n### Bug description:\nWhile working around with my previous issue, I found another TSAN alarm.\n\n```python\nfrom threading import Thread\nimport random\nimport copy\n\nE = Exception()\n\ndef test1():\n for _ in range(100):\n setattr(E, 'x', random.randint(0,1000))\n copy.copy(E)\n\ndef main():\n threads = []\n for _ in range(4):\n threads.append(Thread(target=test1))\n\n for t in threads:\n t.start()\n\n for t in threads:\n t.join()\n\nif __name__ == \"__main__\":\n main()\n```\n\nTSAN report:\n```\nWARNING: ThreadSanitizer: data race (pid=455134)\n Read of size 8 at 0x7fffb60c01b0 by thread T1:\n #0 _PyDict_Next /cpython/Objects/dictobject.c:3020:40 (python3.15t+0x291d09) \n #1 PyDict_Next /cpython/Objects/dictobject.c:3074:12 (python3.15t+0x291d09)\n #2 BaseException___setstate___impl /cpython/Objects/exceptions.c:245:16 (python3.15t+0x232246) \n #3 BaseException___setstate__ /cpython/Objects/clinic/exceptions.c.h:48:20 (python3.15t+0x232246)\n #4 method_vectorcall_O /cpython/Objects/descrobject.c:476:24 (python3.15t+0x2262d5) \n #5 _PyObject_VectorcallTstate /cpython/./Include/internal/pycore_call.h:136:11 (python3.15t+0x20c593) \n #6 PyObject_Vectorcall /cpython/Objects/call.c:327:12 (python3.15t+0x20c593)\n #7 _Py_VectorCallInstrumentation_StackRefSteal /cpython/Python/ceval.c:762:11 (python3.15t+0x422cbc) \n #8 _PyEval_EvalFrameDefault /cpython/Python/generated_cases.c.h:1817:35 (python3.15t+0x428ce6) \n #9 _PyEval_EvalFrame /cpython/./Include/internal/pycore_ceval.h:118:16 (python3.15t+0x422090) \n #10 _PyEval_Vector /cpython/Python/ceval.c:2125:12 (python3.15t+0x422090)\n #11 _PyFunction_Vectorcall /cpython/Objects/call.c (python3.15t+0x20cc0f) \n #12 _PyObject_VectorcallTstate /cpython/./Include/internal/pycore_call.h:136:11 (python3.15t+0x2112e6) \n #13 method_vectorcall /cpython/Objects/classobject.c:74:20 (python3.15t+0x2112e6)\n #14 _PyObject_VectorcallTstate /cpython/./Include/internal/pycore_call.h:136:11 (python3.15t+0x476281) \n #15 context_run /cpython/Python/context.c:727:29 (python3.15t+0x476281)\n #16 method_vectorcall_FASTCALL_KEYWORDS /cpython/Objects/descrobject.c:421:24 (python3.15t+0x226017) \n #17 _PyObject_VectorcallTstate /cpython/./Include/internal/pycore_call.h:136:11 (python3.15t+0x20c593) \n #18 PyObject_Vectorcall /cpython/Objects/call.c:327:12 (python3.15t+0x20c593)\n #19 _Py_VectorCallInstrumentation_StackRefSteal /cpython/Python/ceval.c:762:11 (python3.15t+0x422cbc) \n #20 _PyEval_EvalFrameDefault /cpython/Python/generated_cases.c.h:1817:35 (python3.15t+0x428ce6) \n #21 _PyEval_EvalFrame /cpython/./Include/internal/pycore_ceval.h:118:16 (python3.15t+0x422090) \n #22 _PyEval_Vector /cpython/Python/ceval.c:2125:12 (python3.15t+0x422090)\n #23 _PyFunction_Vectorcall /cpython/Objects/call.c (python3.15t+0x20cc0f) \n #24 _PyObject_VectorcallTstate /cpython/./Include/internal/pycore_call.h:136:11 (python3.15t+0x2112e6) \n #25 method_vectorcall /cpython/Objects/classobject.c:74:20 (python3.15t+0x2112e6)\n #26 _PyVectorcall_Call /cpython/Objects/call.c:273:16 (python3.15t+0x20c89b) \n #27 _PyObject_Call /cpython/Objects/call.c:348:16 (python3.15t+0x20c89b)\n #28 PyObject_Call /cpython/Objects/call.c:373:12 (python3.15t+0x20c905) \n #29 thread_run /cpython/./Modules/_threadmodule.c:387:21 (python3.15t+0x5f5512) \n #30 pythread_wrapper /cpython/Python/thread_pthread.h:234:5 (python3.15t+0x526127) \n\n Previous atomic write of size 8 at 0x7fffb60c01b0 by thread T2:\n #0 _Py_atomic_store_ptr_release /cpython/./Include/cpython/pyatomic_gcc.h:565:3 (python3.15t+0x29435b) \n #1 insertdict /cpython/Objects/dictobject.c (python3.15t+0x29435b)\n #2 setitem_take2_lock_held /cpython/Objects/dictobject.c:2684:12 (python3.15t+0x2936a7) \n #3 setitem_lock_held /cpython/Objects/dictobject.c:2721:12 (python3.15t+0x29ff83) \n #4 _PyDict_SetItem_LockHeld /cpython/Objects/dictobject.c:6850:16 (python3.15t+0x29ff83)\n #5 _PyObjectDict_SetItem /cpython/Objects/dictobject.c:7549:11 (python3.15t+0x2a3d97) \n #6 _PyObject_GenericSetAttrWithDict /cpython/Objects/object.c:2055:19 (python3.15t+0x2cbf44) \n #7 PyObject_GenericSetAttr /cpython/Objects/object.c:2083:12 (python3.15t+0x2cc697) \n #8 PyObject_SetAttr /cpython/Objects/object.c:1528:15 (python3.15t+0x2c8f4f) \n #9 builtin_setattr_impl /cpython/Python/bltinmodule.c:1744:9 (python3.15t+0x41d2e7) \n #10 builtin_setattr /cpython/Python/clinic/bltinmodule.c.h:692:20 (python3.15t+0x41d2e7)\n #11 cfunction_vectorcall_FASTCALL /cpython/Objects/methodobject.c:449:24 (python3.15t+0x2bbb1e) \n #12 _PyObject_VectorcallTstate /cpython/./Include/internal/pycore_call.h:136:11 (python3.15t+0x20c593) \n #13 PyObject_Vectorcall /cpython/Objects/call.c:327:12 (python3.15t+0x20c593)\n #14 _Py_VectorCallInstrumentation_StackRefSteal /cpython/Python/ceval.c:762:11 (python3.15t+0x422cbc) \n #15 _PyEval_EvalFrameDefault /cpython/Python/generated_cases.c.h:1817:35 (python3.15t+0x428ce6) \n #16 _PyEval_EvalFrame /cpython/./Include/internal/pycore_ceval.h:118:16 (python3.15t+0x422090) \n #17 _PyEval_Vector /cpython/Python/ceval.c:2125:12 (python3.15t+0x422090)\n #18 _PyFunction_Vectorcall /cpython/Objects/call.c (python3.15t+0x20cc0f) \n #19 _PyObject_VectorcallTstate /cpython/./Include/internal/pycore_call.h:136:11 (python3.15t+0x2112e6) \n #20 method_vectorcall /cpython/Objects/classobject.c:74:20 (python3.15t+0x2112e6)\n #21 _PyObject_VectorcallTstate /cpython/./Include/internal/pycore_call.h:136:11 (python3.15t+0x476281) \n #22 context_run /cpython/Python/context.c:727:29 (python3.15t+0x476281)\n #23 method_vectorcall_FASTCALL_KEYWORDS /cpython/Objects/descrobject.c:421:24 (python3.15t+0x226017) \n #24 _PyObject_VectorcallTstate /cpython/./Include/internal/pycore_call.h:136:11 (python3.15t+0x20c593) \n #25 PyObject_Vectorcall /cpython/Objects/call.c:327:12 (python3.15t+0x20c593)\n #26 _Py_VectorCallInstrumentation_StackRefSteal /cpython/Python/ceval.c:762:11 (python3.15t+0x422cbc) \n #27 _PyEval_EvalFrameDefault /cpython/Python/generated_cases.c.h:1817:35 (python3.15t+0x428ce6) \n #28 _PyEval_EvalFrame /cpython/./Include/internal/pycore_ceval.h:118:16 (python3.15t+0x422090) \n #29 _PyEval_Vector /cpython/Python/ceval.c:2125:12 (python3.15t+0x422090)\n #30 _PyFunction_Vectorcall /cpython/Objects/call.c (python3.15t+0x20cc0f) \n #31 _PyObject_VectorcallTstate /cpython/./Include/internal/pycore_call.h:136:11 (python3.15t+0x2112e6) \n #32 method_vectorcall /cpython/Objects/classobject.c:74:20 (python3.15t+0x2112e6)\n #33 _PyVectorcall_Call /cpython/Objects/call.c:273:16 (python3.15t+0x20c89b) \n #34 _PyObject_Call /cpython/Objects/call.c:348:16 (python3.15t+0x20c89b)\n #35 PyObject_Call /cpython/Objects/call.c:373:12 (python3.15t+0x20c905) \n #36 thread_run /cpython/./Modules/_threadmodule.c:387:21 (python3.15t+0x5f5512) \n #37 pythread_wrapper /cpython/Python/thread_pthread.h:234:5 (python3.15t+0x526127) \n\nSUMMARY: ThreadSanitizer: data race /cpython/Objects/dictobject.c:3020:40 in _PyDict_Next\n```\nVersion: Python 3.15.0a5+ free-threading build (heads/main:d5f96c86653, Feb 11 2026, 04:50:14) [Clang 18.1.3 (1ubuntu1)]\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-144828\n* gh-150578\n* gh-153746\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/Naserume","@type":"Person","name":"Naserume"},"datePublished":"2026-02-13T02:57:44.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/144774/cpython/issues/144774"}
| 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:d847d803-1869-8b95-6d0f-d4a8c683ecbd |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9076:13123D:8F488:C1BA2:6A57F325 |
| html-safe-nonce | 9e89436a58ed9fa79bccf90cde1f7948735d4802f15f7566041bf560f24d3437 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MDc2OjEzMTIzRDo4RjQ4ODpDMUJBMjo2QTU3RjMyNSIsInZpc2l0b3JfaWQiOiIzOTY1NDcwNzY0MTgzMzE5MzMzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | dc53bd0ca67f562d376cad1c2dbed69a7ff0df2b06330a38b510be0df4e02f1c |
| hovercard-subject-tag | issue:3935071535 |
| 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/144774/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c83e2c7c36747f7609ec519765bec24d0ff5cb8a8b5b4c0d518917e84d9020d5/python/cpython/issues/144774 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c83e2c7c36747f7609ec519765bec24d0ff5cb8a8b5b4c0d518917e84d9020d5/python/cpython/issues/144774 |
| og:image:alt | Bug report Bug description: While working around with my previous issue, I found another TSAN alarm. from threading import Thread import random import copy E = Exception() def test1(): for _ in ran... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Naserume |
| hostname | github.com |
| expected-hostname | github.com |
| None | 49c8c15fabcbf356d607a90ca115c13b273e42ff8b74155de050fd229a9b0121 |
| 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 | 3fb1f684e7a833eb1b2d01d39875a2b52cb4fe9b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width