René's URL Explorer Experiment


Title: gh-132942: Fix races in type lookup cache by nascheme · Pull Request #133032 · python/cpython · GitHub

Open Graph Title: gh-132942: Fix races in type lookup cache by nascheme · Pull Request #133032 · python/cpython

X Title: gh-132942: Fix races in type lookup cache by nascheme · Pull Request #133032 · python/cpython

Description: Two races related to the type lookup cache, when used in the free-threaded build. This caused test_opcache to sometimes fail (as well as other hard to reproduce failures). The first problem is that find_name_in_mro() can block on some mutex and then release critical sections. If that happens, the type version used for the cache entry can be wrong (too new). Assigning the version before doing the find fixes this issue. If it does race, you will add an entry that uses an out-of-date version. The second problem was much harder to track down. There is a hard to trigger race in update_cache(), writing to cache, and _PyType_LookupStackRefAndVersion(), reading from cache. We use a sequence lock to avoid races. However, if the reader reads the old entry value and the new entry version, it will try to execute _Py_TryXGetStackRef() on a stale cache entry value. If that value has been deallocated, PyStackRef_XCLOSE() will crash. This could happen before because the version was written first and then new value second. The fix is simply to write the entry value first and the version after. That way, the reader always sees a value at least as new as the version. Possible scenarios for the reader of the cache entry, as it is being written to concurrently: entry version entry value outcome old old Okay, type version will not match old new Okay, incref/decref works, seq check fails new old Bad, incref/decref on old value might crash new new Okay, incref/decref works, seq check fails Issue: gh-132942

Open Graph Description: Two races related to the type lookup cache, when used in the free-threaded build. This caused test_opcache to sometimes fail (as well as other hard to reproduce failures). The first problem is tha...

X Description: Two races related to the type lookup cache, when used in the free-threaded build. This caused test_opcache to sometimes fail (as well as other hard to reproduce failures). The first problem is tha...

Opengraph URL: https://github.com/python/cpython/pull/133032

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:e93e6eae-0eed-acef-9111-989dca2044c3
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idADE2:1F466:40C48C:578AC2:6A5801C7
html-safe-nonce7ee670ae31015f54e23736d8486957bc137a09d1ac6e68cad5141c459c19b3ed
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBREUyOjFGNDY2OjQwQzQ4Qzo1NzhBQzI6NkE1ODAxQzciLCJ2aXNpdG9yX2lkIjoiMTk2MzQ0OTU1Mzg5NTU1NTUyNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac6b84da00dd94f86d27a483e859171f3cea684537fa7ae661f1d1f0108abc2838
hovercard-subject-tagpull_request:2483735062
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/133032/files
twitter:imagehttps://avatars.githubusercontent.com/u/690853?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/690853?s=400&v=4
og:image:altTwo races related to the type lookup cache, when used in the free-threaded build. This caused test_opcache to sometimes fail (as well as other hard to reproduce failures). The first problem is tha...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None49c8c15fabcbf356d607a90ca115c13b273e42ff8b74155de050fd229a9b0121
turbo-cache-controlno-preview
diff-viewunified
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 full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release3fb1f684e7a833eb1b2d01d39875a2b52cb4fe9b
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/133032/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F133032%2Ffiles
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%2Fpull%2F133032%2Ffiles
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%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/133032/files
Reloadhttps://github.com/python/cpython/pull/133032/files
Reloadhttps://github.com/python/cpython/pull/133032/files
Please reload this pagehttps://github.com/python/cpython/pull/133032/files
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/133032/files
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
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
naschemehttps://github.com/nascheme
python:mainhttps://github.com/python/cpython/tree/main
nascheme:gh-132942-tp-lookup-racehttps://github.com/nascheme/cpython/tree/gh-132942-tp-lookup-race
Conversation 6 https://github.com/python/cpython/pull/133032
Commits 4 https://github.com/python/cpython/pull/133032/commits
Checks 0 https://github.com/python/cpython/pull/133032/checks
Files changed https://github.com/python/cpython/pull/133032/files
Please reload this pagehttps://github.com/python/cpython/pull/133032/files
gh-132942: Fix races in type lookup cache https://github.com/python/cpython/pull/133032/files#top
Show all changes 4 commits https://github.com/python/cpython/pull/133032/files
90a7d35 gh-132942: Fix races in type lookup cache nascheme Apr 27, 2025 https://github.com/python/cpython/pull/133032/commits/90a7d35ab3c0dd2302351917811d19c8513fd001
5cd03e8 Add NEWS. nascheme Apr 27, 2025 https://github.com/python/cpython/pull/133032/commits/5cd03e856b3b31669158df2707640408e29eeb0c
6d30841 Use release/acquire pair for entry->version. nascheme Apr 28, 2025 https://github.com/python/cpython/pull/133032/commits/6d3084113488cc2861238e50046d588d6b6230e0
3e01796 Merge 'origin/main' into gh-132942-tp-lookup-race nascheme Apr 28, 2025 https://github.com/python/cpython/pull/133032/commits/3e0179612ef43e1605a7121519afaab1844927c5
Clear filters https://github.com/python/cpython/pull/133032/files
Please reload this pagehttps://github.com/python/cpython/pull/133032/files
Please reload this pagehttps://github.com/python/cpython/pull/133032/files
2025-04-26-17-50-47.gh-issue-132942.aEEZvZ.rst https://github.com/python/cpython/pull/133032/files#diff-66865d4a81a04991bbf7a731ca900140633ae37c6c9918da91ae8c205a2d3532
typeobject.c https://github.com/python/cpython/pull/133032/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872
Misc/NEWS.d/next/Core_and_Builtins/2025-04-26-17-50-47.gh-issue-132942.aEEZvZ.rsthttps://github.com/python/cpython/pull/133032/files#diff-66865d4a81a04991bbf7a731ca900140633ae37c6c9918da91ae8c205a2d3532
View file https://github.com/nascheme/cpython/blob/3e0179612ef43e1605a7121519afaab1844927c5/Misc/NEWS.d/next/Core_and_Builtins/2025-04-26-17-50-47.gh-issue-132942.aEEZvZ.rst
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/133032/{{ revealButtonHref }}
https://github.com/python/cpython/blob/main/.github/CODEOWNERS#L220
Objects/typeobject.chttps://github.com/python/cpython/pull/133032/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872
View file https://github.com/nascheme/cpython/blob/3e0179612ef43e1605a7121519afaab1844927c5/Objects/typeobject.c
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/python/cpython/pull/133032/{{ revealButtonHref }}
https://github.com/python/cpython/pull/133032/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872
https://github.com/python/cpython/pull/133032/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872
https://github.com/python/cpython/pull/133032/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872
https://github.com/python/cpython/pull/133032/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872
https://github.com/python/cpython/pull/133032/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872
https://github.com/python/cpython/pull/133032/files#diff-1decebeef15f4e0b0ce106c665751ec55068d4d1d1825847925ad4f528b5b872
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.