René's URL Explorer Experiment


Title: data races in decimal module with global context · Issue #141148 · python/cpython · GitHub

Open Graph Title: data races in decimal module with global context · Issue #141148 · python/cpython

X Title: data races in decimal module with global context · Issue #141148 · python/cpython

Description: Reproducer: import decimal from threading import Thread, Barrier context = decimal.Context() context.prec = 28 barrier = Barrier(10) def race(): barrier.wait() decimal.Decimal('1.0', context=context) if __name__ == "__main__": while True...

Open Graph Description: Reproducer: import decimal from threading import Thread, Barrier context = decimal.Context() context.prec = 28 barrier = Barrier(10) def race(): barrier.wait() decimal.Decimal('1.0', context=contex...

X Description: Reproducer: import decimal from threading import Thread, Barrier context = decimal.Context() context.prec = 28 barrier = Barrier(10) def race(): barrier.wait() decimal.Decimal('1.0', contex...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"data races in decimal module with global context","articleBody":"Reproducer:\n```py\nimport decimal\nfrom threading import Thread, Barrier\n\ncontext = decimal.Context()\ncontext.prec = 28\n\nbarrier = Barrier(10)\n\ndef race():\n    barrier.wait()\n    decimal.Decimal('1.0', context=context)\n\nif __name__ == \"__main__\":\n    while True:\n        threads = [Thread(target=race) for _ in range(10)]\n        for thread in threads:\n            thread.start()\n        for thread in threads:\n            thread.join()\n```\n\nData race:\n```console\n==================\nWARNING: ThreadSanitizer: data race (pid=58514)\n  Write of size 4 at 0x00010d315cbc by thread T5808:\n    #0 dec_addstatus _decimal.c:612 (_decimal.cpython-315t-darwin.so:arm64+0x9a88)\n    #1 PyDecType_FromCStringExact _decimal.c:2323 (_decimal.cpython-315t-darwin.so:arm64+0x1a4a4)\n    #2 dec_new _decimal.c.h:572 (_decimal.cpython-315t-darwin.so:arm64+0x506c)\n    #3 type_call typeobject.c:2432 (python.exe:arm64+0x10017e768)\n    #4 _PyObject_MakeTpCall call.c:242 (python.exe:arm64+0x10007eb64)\n    #5 PyObject_Vectorcall call.c:327 (python.exe:arm64+0x10007f750)\n    #6 _PyEval_EvalFrameDefault generated_cases.c.h:1620 (python.exe:arm64+0x100277dec)\n    #7 _PyEval_Vector ceval.c:1989 (python.exe:arm64+0x10026ad88)\n    #8 _PyFunction_Vectorcall call.c (python.exe:arm64+0x10007fcec)\n    #9 method_vectorcall classobject.c:65 (python.exe:arm64+0x100084190)\n    #10 _PyObject_Call call.c:348 (python.exe:arm64+0x10007f8b0)\n    #11 PyObject_Call call.c:373 (python.exe:arm64+0x10007f9d8)\n    #12 _PyEval_EvalFrameDefault generated_cases.c.h:2616 (python.exe:arm64+0x10027bf64)\n    #13 _PyEval_Vector ceval.c:1989 (python.exe:arm64+0x10026ad88)\n    #14 _PyFunction_Vectorcall call.c (python.exe:arm64+0x10007fcec)\n    #15 method_vectorcall classobject.c:73 (python.exe:arm64+0x10008422c)\n    #16 context_run context.c:728 (python.exe:arm64+0x1002b53dc)\n    #17 _PyEval_EvalFrameDefault generated_cases.c.h:3710 (python.exe:arm64+0x10027ffbc)\n    #18 _PyEval_Vector ceval.c:1989 (python.exe:arm64+0x10026ad88)\n    #19 _PyFunction_Vectorcall call.c (python.exe:arm64+0x10007fcec)\n    #20 method_vectorcall classobject.c:73 (python.exe:arm64+0x10008422c)\n    #21 _PyObject_Call call.c:348 (python.exe:arm64+0x10007f964)\n    #22 PyObject_Call call.c:373 (python.exe:arm64+0x10007f9d8)\n    #23 thread_run _threadmodule.c:387 (python.exe:arm64+0x10041b338)\n    #24 pythread_wrapper thread_pthread.h:234 (python.exe:arm64+0x100358824)\n\n  Previous write of size 4 at 0x00010d315cbc by thread T5806:\n    #0 dec_addstatus _decimal.c:612 (_decimal.cpython-315t-darwin.so:arm64+0x9a88)\n    #1 PyDecType_FromCStringExact _decimal.c:2323 (_decimal.cpython-315t-darwin.so:arm64+0x1a4a4)\n    #2 dec_new _decimal.c.h:572 (_decimal.cpython-315t-darwin.so:arm64+0x506c)\n    #3 type_call typeobject.c:2432 (python.exe:arm64+0x10017e768)\n    #4 _PyObject_MakeTpCall call.c:242 (python.exe:arm64+0x10007eb64)\n    #5 PyObject_Vectorcall call.c:327 (python.exe:arm64+0x10007f750)\n    #6 _PyEval_EvalFrameDefault generated_cases.c.h:1620 (python.exe:arm64+0x100277dec)\n    #7 _PyEval_Vector ceval.c:1989 (python.exe:arm64+0x10026ad88)\n    #8 _PyFunction_Vectorcall call.c (python.exe:arm64+0x10007fcec)\n    #9 method_vectorcall classobject.c:65 (python.exe:arm64+0x100084190)\n    #10 _PyObject_Call call.c:348 (python.exe:arm64+0x10007f8b0)\n    #11 PyObject_Call call.c:373 (python.exe:arm64+0x10007f9d8)\n    #12 _PyEval_EvalFrameDefault generated_cases.c.h:2616 (python.exe:arm64+0x10027bf64)\n    #13 _PyEval_Vector ceval.c:1989 (python.exe:arm64+0x10026ad88)\n    #14 _PyFunction_Vectorcall call.c (python.exe:arm64+0x10007fcec)\n    #15 method_vectorcall classobject.c:73 (python.exe:arm64+0x10008422c)\n    #16 context_run context.c:728 (python.exe:arm64+0x1002b53dc)\n    #17 _PyEval_EvalFrameDefault generated_cases.c.h:3710 (python.exe:arm64+0x10027ffbc)\n    #18 _PyEval_Vector ceval.c:1989 (python.exe:arm64+0x10026ad88)\n    #19 _PyFunction_Vectorcall call.c (python.exe:arm64+0x10007fcec)\n    #20 method_vectorcall classobject.c:73 (python.exe:arm64+0x10008422c)\n    #21 _PyObject_Call call.c:348 (python.exe:arm64+0x10007f964)\n    #22 PyObject_Call call.c:373 (python.exe:arm64+0x10007f9d8)\n    #23 thread_run _threadmodule.c:387 (python.exe:arm64+0x10041b338)\n    #24 pythread_wrapper thread_pthread.h:234 (python.exe:arm64+0x100358824)\nSUMMARY: ThreadSanitizer: data race _decimal.c:615 in dec_addstatus\n==================\n```\n\nI discovered this while adding thread safety support to [msgspec](https://github.com/jcrist/msgspec). Running its test suite under pytest-run-parallel leads to similar data races as present above from the minimal reproducer. \n\nSee https://gist.github.com/kumaraditya303/3c26f31eaf0beea39d7eeb539b662846 for full tsan report\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-146482\n* gh-151953\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/kumaraditya303","@type":"Person","name":"kumaraditya303"},"datePublished":"2025-11-06T14:54:31.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":16},"url":"https://github.com/141148/cpython/issues/141148"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:f2d028c2-c6fa-26e5-8cb7-1b014f1a1a6a
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD640:22A236:77DF3:A1CC7:6A532A90
html-safe-nonce582663e673b7cf419e92858413f0579ef816993781bbdcfd4f139b68e3a4a693
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjQwOjIyQTIzNjo3N0RGMzpBMUNDNzo2QTUzMkE5MCIsInZpc2l0b3JfaWQiOiI2MTQwMDM5MTg4OTE2MTUyOTc2IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac80e11343d8c8ebfe038e8570f28e2144b0413a78aea92e85c1cf1fa9c90cbc17
hovercard-subject-tagissue:3596171795
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/141148/issue_layout
twitter:imagehttps://opengraph.githubassets.com/80a521ec9b56f6cf6148ea1d88ace36d7f9f530e0f594dc9152e85f9faab9999/python/cpython/issues/141148
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/80a521ec9b56f6cf6148ea1d88ace36d7f9f530e0f594dc9152e85f9faab9999/python/cpython/issues/141148
og:image:altReproducer: import decimal from threading import Thread, Barrier context = decimal.Context() context.prec = 28 barrier = Barrier(10) def race(): barrier.wait() decimal.Decimal('1.0', context=contex...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamekumaraditya303
hostnamegithub.com
expected-hostnamegithub.com
Noneb9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb
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
release07a982c1d40157c619b364352b704c3ce66bb332
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/issues/141148#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F141148
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
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
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
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/enterprise/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%2F141148
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/141148
Reloadhttps://github.com/python/cpython/issues/141148
Reloadhttps://github.com/python/cpython/issues/141148
Please reload this pagehttps://github.com/python/cpython/issues/141148
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/issues/141148
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 35k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 73.8k 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.3k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security and quality 0 https://github.com/python/cpython/security
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 and quality https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
data races in decimal module with global contexthttps://github.com/python/cpython/issues/141148#top
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%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/kumaraditya303
kumaraditya303https://github.com/kumaraditya303
on Nov 6, 2025https://github.com/python/cpython/issues/141148#issue-3596171795
msgspechttps://github.com/jcrist/msgspec
https://gist.github.com/kumaraditya303/3c26f31eaf0beea39d7eeb539b662846https://gist.github.com/kumaraditya303/3c26f31eaf0beea39d7eeb539b662846
GH-141148: ensure tasks/threads get fresh copy of decimal.Context #146482https://github.com/python/cpython/pull/146482
GH-141148: Ensure decimal.getcontext() returns fresh copy. #151953https://github.com/python/cpython/pull/151953
docsDocumentation in the Doc dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22docs%22
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%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
docs issueshttps://github.com/orgs/python/projects/52
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.