René's URL Explorer Experiment


Title: TSAN warnings in dictobject.c · Issue #142534 · python/cpython · GitHub

Open Graph Title: TSAN warnings in dictobject.c · Issue #142534 · python/cpython

X Title: TSAN warnings in dictobject.c · Issue #142534 · python/cpython

Description: A LazyImports test is generating TSAN warnings that look something like: WARNING: ThreadSanitizer: data race (pid=453778) Read of size 8 at 0x567fc2060568 by thread T3: #0 _Py_TYPE_impl /home/sgross/cpython/./Include/object.h:313:16 (pyt...

Open Graph Description: A LazyImports test is generating TSAN warnings that look something like: WARNING: ThreadSanitizer: data race (pid=453778) Read of size 8 at 0x567fc2060568 by thread T3: #0 _Py_TYPE_impl /home/sgros...

X Description: A LazyImports test is generating TSAN warnings that look something like: WARNING: ThreadSanitizer: data race (pid=453778) Read of size 8 at 0x567fc2060568 by thread T3: #0 _Py_TYPE_impl /home/sgros...

Opengraph URL: https://github.com/python/cpython/issues/142534

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TSAN warnings in dictobject.c","articleBody":"A [LazyImports test](https://github.com/LazyImportsCabal/cpython/blob/31b7fe99cac75ca887b38192663918e76f1733d4/Lib/test/test_import/test_lazy_imports.py#L1439-L1472) is generating TSAN warnings that look something like:\n\n```\nWARNING: ThreadSanitizer: data race (pid=453778)\n  Read of size 8 at 0x567fc2060568 by thread T3:\n    #0 _Py_TYPE_impl /home/sgross/cpython/./Include/object.h:313:16 (python+0x3265a1) (BuildId: 149c3950b350c299f7b543875dac3ce12f85640f)\n    #1 _Py_IS_TYPE_impl /home/sgross/cpython/./Include/object.h:328:12 (python+0x3265a1)\n    #2 compare_unicode_unicode_threadsafe /home/sgross/cpython/Objects/dictobject.c:1424:13 (python+0x3265a1)\n    #3 do_lookup /home/sgross/cpython/Objects/dictobject.c:1009:23 (python+0x325b48) (BuildId: 149c3950b350c299f7b543875dac3ce12f85640f)\n    #4 unicodekeys_lookup_unicode_threadsafe /home/sgross/cpython/Objects/dictobject.c:1445:12 (python+0x30d85f) (BuildId: 149c3950b350c299f7b543875dac3ce12f85640f)\n\n...\n\n   Previous write of size 8 at 0x567fc2060568 by thread T2:\n    #0 __tsan_memset \u003cnull\u003e (python+0xf5c91) (BuildId: 149c3950b350c299f7b543875dac3ce12f85640f)\n    #1 fill_mem_debug /home/sgross/cpython/Objects/obmalloc.c (python+0x37b9f9) (BuildId: 149c3950b350c299f7b543875dac3ce12f85640f)\n    #2 _PyMem_DebugRawAlloc /home/sgross/cpython/Objects/obmalloc.c:2904:9 (python+0x37b9f9)\n    #3 _PyMem_DebugRawMalloc /home/sgross/cpython/Objects/obmalloc.c:2920:12 (python+0x37b9f9)\n    #4 _PyMem_DebugMalloc /home/sgross/cpython/Objects/obmalloc.c:3085:12 (python+0x37b9f9)\n    #5 PyObject_Malloc /home/sgross/cpython/Objects/obmalloc.c:1493:12 (python+0x37a41d) (BuildId: 149c3950b350c299f7b543875dac3ce12f85640f)\n    #6 PyUnicode_New /home/sgross/cpython/Objects/unicodeobject.c:1320:24 (python+0x3fd681) (BuildId: 149c3950b350c299f7b543875dac3ce12f85640f)\n...\n```\n\nThe problem is that the reader is using \"relaxed\" memory ordering. (The writer is using \"release\", which is good).\n\nhttps://github.com/python/cpython/blob/46295677a13f141b8d52cc36202384554adba65d/Objects/dictobject.c#L1416-L1417\n\nThis is a case where the C11 memory model isn't a good fit for actual hardware. The C11 memory model requires at least \"consume\", but compilers treat \"consume\" like the stronger \"acquire\", which emits stronger than necessary fences on aarch64 [^1]. \"consume\" should be \"free\" on aarch64, but \"acquire\" requires a load with a fence like `LDAR/LDAPR`.\n\nWe have a few options:\n\n1) Keep using \"relaxed\" and sometimes trigger TSAN warnings -- not great\n2) Use \"acquire\" and suffer a potential performance hit on aarch64\n3) Add fake \"consume\" bindings in pyatomic.h that are \"acquire\" under TSAN and \"relaxed\" otherwise\n\nI think (3) is the best option, but I'll benchmark (2). \n\n### FAQ\n\n\u003e Would #3 mean that we're not doing the right thing on aarch64 though?\n\nNo, we'd be doing the right thing. A plain load is sufficient on aarch64 (and x86-64, POWER, armv7, SPARC, etc.) and pretty much every mainstream CPU in existence, except (famously) the DEC Alpha, which hasn't been manufactured in two decades. CPUs (except the DEC Alpha) respect address dependencies -- they won't reorder dependent loads.\n\n### References\n\n* [P2055R0: A Relaxed Guide to memory_order_relaxed](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2055r0.pdf) - see 2.6.7\n* https://docs.kernel.org/core-api/wrappers/memory-barriers.html - see `READ_ONCE`, which is the Linux kernel counterpart to `memory_order_relaxed`\n* [Is Parallel Programming Hard, And, If So, What Can You Do About It?](https://www.kernel.org/pub/linux/kernel/people/paulmck/perfbook/perfbook.html) - see 15.3.4 Address Dependencies\n* [P0190R4: Proposal for New memory order consume Definition](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0190r4.pdf)\n\n[^1]: There's no performance issue when using \"acquire\" on x86-64 because plain loads have \"acquire\" semantics so \"acquire\" is free.\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-142544\n* gh-142603\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/colesbury","@type":"Person","name":"colesbury"},"datePublished":"2025-12-10T20:05:24.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/142534/cpython/issues/142534"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:91491e44-93c5-537d-acb5-1f77e04f3b6e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-id83BA:1F1AF5:9DF91E:D78124:6969EE54
html-safe-nonce2a903c70d635a1a9dd8de3a2e2c901a79923b20af7e239032adacf64abaad7aa
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4M0JBOjFGMUFGNTo5REY5MUU6RDc4MTI0OjY5NjlFRTU0IiwidmlzaXRvcl9pZCI6IjM2NzA4ODcxNjkzMTI1NTA0ODQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac36be5be70ed8a29b51808f333077328b0df8f46e2b643fb0e2490fa4dd537e19
hovercard-subject-tagissue:3716607025
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/142534/issue_layout
twitter:imagehttps://opengraph.githubassets.com/6ffc7089827780541c1715c9f3e60271105085448fa9ca27110747761f18cd26/python/cpython/issues/142534
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/6ffc7089827780541c1715c9f3e60271105085448fa9ca27110747761f18cd26/python/cpython/issues/142534
og:image:altA LazyImports test is generating TSAN warnings that look something like: WARNING: ThreadSanitizer: data race (pid=453778) Read of size 8 at 0x567fc2060568 by thread T3: #0 _Py_TYPE_impl /home/sgros...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamecolesbury
hostnamegithub.com
expected-hostnamegithub.com
None7b32f1c7c4549428ee399213e8345494fc55b5637195d3fc5f493657579235e8
turbo-cache-controlno-preview
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasebdde15ad1b403e23b08bbd89b53fbe6bdf688cad
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/142534#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F142534
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F142534
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/issues/142534
Reloadhttps://github.com/python/cpython/issues/142534
Reloadhttps://github.com/python/cpython/issues/142534
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/142534
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 33.9k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/python/cpython/security
Please reload this pagehttps://github.com/python/cpython/issues/142534
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/142534
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/142534
TSAN warnings in dictobject.chttps://github.com/python/cpython/issues/142534#top
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/colesbury
https://github.com/colesbury
colesburyhttps://github.com/colesbury
on Dec 10, 2025https://github.com/python/cpython/issues/142534#issue-3716607025
LazyImports testhttps://github.com/LazyImportsCabal/cpython/blob/31b7fe99cac75ca887b38192663918e76f1733d4/Lib/test/test_import/test_lazy_imports.py#L1439-L1472
cpython/Objects/dictobject.chttps://github.com/python/cpython/blob/46295677a13f141b8d52cc36202384554adba65d/Objects/dictobject.c#L1416-L1417
4629567https://github.com/python/cpython/commit/46295677a13f141b8d52cc36202384554adba65d
1https://github.com/python/cpython/issues/142534#user-content-fn-1-61c64600a3b613cc6494e094ddb7a62f
#3https://github.com/python/cpython/pull/3
P2055R0: A Relaxed Guide to memory_order_relaxedhttps://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p2055r0.pdf
https://docs.kernel.org/core-api/wrappers/memory-barriers.htmlhttps://docs.kernel.org/core-api/wrappers/memory-barriers.html
Is Parallel Programming Hard, And, If So, What Can You Do About It?https://www.kernel.org/pub/linux/kernel/people/paulmck/perfbook/perfbook.html
P0190R4: Proposal for New memory order consume Definitionhttps://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0190r4.pdf
gh-142534: Avoid TSan warnings in dictobject.c #142544https://github.com/python/cpython/pull/142544
[3.14] gh-142534: Avoid TSan warnings in dictobject.c (gh-142544) #142603https://github.com/python/cpython/pull/142603
https://github.com/python/cpython/issues/142534#user-content-fnref-1-61c64600a3b613cc6494e094ddb7a62f
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.