Title: `_Py_atomic_load_uint16` incorrect in `pyatomic_std.h` · Issue #146227 · python/cpython · GitHub
Open Graph Title: `_Py_atomic_load_uint16` incorrect in `pyatomic_std.h` · Issue #146227 · python/cpython
X Title: `_Py_atomic_load_uint16` incorrect in `pyatomic_std.h` · Issue #146227 · python/cpython
Description: Bug report Found by Mohammed Zuhaib in https://discuss.python.org/t/code-explanation-for-absence-of-stdatomic-h-for-python-build/101623/30. cpython/Include/cpython/pyatomic_std.h Lines 458 to 463 in 6450b1d static inline uint16_t _Py_ato...
Open Graph Description: Bug report Found by Mohammed Zuhaib in https://discuss.python.org/t/code-explanation-for-absence-of-stdatomic-h-for-python-build/101623/30. cpython/Include/cpython/pyatomic_std.h Lines 458 to 463 i...
X Description: Bug report Found by Mohammed Zuhaib in https://discuss.python.org/t/code-explanation-for-absence-of-stdatomic-h-for-python-build/101623/30. cpython/Include/cpython/pyatomic_std.h Lines 458 to 463 i...
Opengraph URL: https://github.com/python/cpython/issues/146227
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`_Py_atomic_load_uint16` incorrect in `pyatomic_std.h`","articleBody":"# Bug report\n\nFound by [Mohammed Zuhaib](https://discuss.python.org/u/zuhu2195) in https://discuss.python.org/t/code-explanation-for-absence-of-stdatomic-h-for-python-build/101623/30.\n\nhttps://github.com/python/cpython/blob/6450b1d142b6254d2e3b2eba47d69125ca79b3fe/Include/cpython/pyatomic_std.h#L458-L463\n\nWe cast to a `uint32_t` instead of `uint16_t`. I suspect this probably doesn't have noticeable effects on little-endian systems, but would load the wrong value on big-endian systems. We also mostly use `pyatomic_gcc.h` or `pyatomic_msvc.h`, which is probably why we didn't catch this in big-endian buildbots.\n\nI asked Claude to review these files. In addition to the above bug:\n\n```\n 2. pyatomic_msc.h:974-978 — _Py_atomic_store_uint_release broken on ARM64\n\n static inline void\n _Py_atomic_store_uint_release(unsigned int *obj, unsigned int value)\n {\n *(volatile unsigned int *)obj = value;\n }\n\n This is placed among the relaxed stores and uses only a volatile store. On x86/x64, volatile stores have release semantics, so this happens to work. But on ARM64, volatile accesses are only relaxed\n (as stated in the file's header comment). Every other _release function in this file (e.g., _Py_atomic_store_int_release at line 1057, _Py_atomic_store_uint32_release at line 1108) properly uses\n __stlr32 on ARM64. This function is missing the #if/#elif ARM64 branch.\n\n 3. pyatomic_gcc.h — Missing _Py_atomic_store_uint_release\n\n Both pyatomic_std.h (line 1035) and pyatomic_msc.h (line 975) define _Py_atomic_store_uint_release, but pyatomic_gcc.h does not. If any code calls it when compiled with GCC/Clang, it would fail to\n link/compile.\n\n 4. pyatomic.h:75-76 — Incorrect pseudo-code comment\n\n def _Py_atomic_store_ptr_release(obj):\n return obj # release\n\n This is documented as a one-arg function that returns a value, but it's actually a two-arg store (like the real declaration at line 518). Should be:\n def _Py_atomic_store_ptr_release(obj, value):\n obj = value # release\n```\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-146229\n* gh-146232\n* gh-146233\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/colesbury","@type":"Person","name":"colesbury"},"datePublished":"2026-03-20T17:05:15.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/146227/cpython/issues/146227"}
| 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:c170fbed-ddd4-ee58-42ed-236ab3af5d53 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E986:3E375C:F899AE:151BCE6:6A507465 |
| html-safe-nonce | 6365f615e2a9df1eb9f7be2c74b590c48a7b2c70d183e74429211200cc22b997 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTg2OjNFMzc1QzpGODk5QUU6MTUxQkNFNjo2QTUwNzQ2NSIsInZpc2l0b3JfaWQiOiIxNTc4ODE0NDA2MjQxODQyMjc3IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 1b3e9ab4fa53f6c2e6808ab554869fda1b9dfb290dbaf27b076c3b4f16b91cf6 |
| hovercard-subject-tag | issue:4109014312 |
| 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/146227/issue_layout |
| twitter:image | https://opengraph.githubassets.com/9c2dd10f1423699cd3d5ee87ab7ea4881d5fd50df9f1b77f1b6f77d2ee433969/python/cpython/issues/146227 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/9c2dd10f1423699cd3d5ee87ab7ea4881d5fd50df9f1b77f1b6f77d2ee433969/python/cpython/issues/146227 |
| og:image:alt | Bug report Found by Mohammed Zuhaib in https://discuss.python.org/t/code-explanation-for-absence-of-stdatomic-h-for-python-build/101623/30. cpython/Include/cpython/pyatomic_std.h Lines 458 to 463 i... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | colesbury |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| 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 | 7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width