Title: PyUnstable_Code_SetExtra and PyUnstable_Code_GetExtra are not thread-safe in free-threaded builds · Issue #144981 · python/cpython · GitHub
Open Graph Title: PyUnstable_Code_SetExtra and PyUnstable_Code_GetExtra are not thread-safe in free-threaded builds · Issue #144981 · python/cpython
X Title: PyUnstable_Code_SetExtra and PyUnstable_Code_GetExtra are not thread-safe in free-threaded builds · Issue #144981 · python/cpython
Description: Bug report Bug description: PyUnstable_Code_SetExtra and PyUnstable_Code_GetExtra in Objects/codeobject.c have no free-threaded protections. The co_extra field is read and written with plain loads and stores, and SetExtra calls PyMem_Rea...
Open Graph Description: Bug report Bug description: PyUnstable_Code_SetExtra and PyUnstable_Code_GetExtra in Objects/codeobject.c have no free-threaded protections. The co_extra field is read and written with plain loads ...
X Description: Bug report Bug description: PyUnstable_Code_SetExtra and PyUnstable_Code_GetExtra in Objects/codeobject.c have no free-threaded protections. The co_extra field is read and written with plain loads ...
Opengraph URL: https://github.com/python/cpython/issues/144981
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"PyUnstable_Code_SetExtra and PyUnstable_Code_GetExtra are not thread-safe in free-threaded builds","articleBody":"# Bug report\n\n### Bug description:\n\n`PyUnstable_Code_SetExtra` and `PyUnstable_Code_GetExtra` in `Objects/codeobject.c` have no free-threaded protections. The `co_extra` field is read and written with plain loads and stores, and `SetExtra` calls `PyMem_Realloc` which can free the old buffer while a concurrent `GetExtra` is reading from it.\n\nSimilarly, `PyUnstable_Eval_RequestCodeExtraIndex` in `Python/ceval.c` increments `co_extra_user_count` and writes to `co_extra_freefuncs` without any synchronization.\n\nThe new tests (#144980) exercise the concurrent paths and a free-threaded TSAN build without the fix crashes/emits warnings.\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-144980\n* gh-145052\n* gh-145327\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/yoney","@type":"Person","name":"yoney"},"datePublished":"2026-02-18T22:56:50.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/144981/cpython/issues/144981"}
| 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:8e82143f-b489-1d79-9fb0-f757b49a07ad |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A0FA:1E9C94:1787CB:203B89:6A583FCA |
| html-safe-nonce | ed190b23abc437d4a5cd5c8b1893a8d5ff20cb20ad0289353144e4048f8d643a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMEZBOjFFOUM5NDoxNzg3Q0I6MjAzQjg5OjZBNTgzRkNBIiwidmlzaXRvcl9pZCI6IjE5MjQzNDA2MTI0OTAzNDY0NDIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 338e1c604a09452e0932fc4a4281eff3250543df2da9f474b97dd7bff924885d |
| hovercard-subject-tag | issue:3960144476 |
| 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/144981/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0d64e5cf3b2c8a61ffce6f791292250b4a9cbf790a30d55027cb6e173d7b596b/python/cpython/issues/144981 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0d64e5cf3b2c8a61ffce6f791292250b4a9cbf790a30d55027cb6e173d7b596b/python/cpython/issues/144981 |
| og:image:alt | Bug report Bug description: PyUnstable_Code_SetExtra and PyUnstable_Code_GetExtra in Objects/codeobject.c have no free-threaded protections. The co_extra field is read and written with plain loads ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | yoney |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f2a0c7865178af3d91dd9f13b0cdfc3c73a2529c873d2780bb4c01271a57ec6 |
| 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 | 8aae7b8d6caacacf5c66eaeb2702d8dc88d85b4a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width