Title: Memory sanitizer generates false positives on data returned by os.getrandom() · Issue #148850 · python/cpython · GitHub
Open Graph Title: Memory sanitizer generates false positives on data returned by os.getrandom() · Issue #148850 · python/cpython
X Title: Memory sanitizer generates false positives on data returned by os.getrandom() · Issue #148850 · python/cpython
Description: Bug report Bug description: When python is built with memory sanitizer enabled, reading any data returned by os.getrandom() will trigger a memory sanitizer false positive, because the buffer is filled using a syscall, and the memory isn'...
Open Graph Description: Bug report Bug description: When python is built with memory sanitizer enabled, reading any data returned by os.getrandom() will trigger a memory sanitizer false positive, because the buffer is fil...
X Description: Bug report Bug description: When python is built with memory sanitizer enabled, reading any data returned by os.getrandom() will trigger a memory sanitizer false positive, because the buffer is fil...
Opengraph URL: https://github.com/python/cpython/issues/148850
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Memory sanitizer generates false positives on data returned by os.getrandom()","articleBody":"# Bug report\n\n### Bug description:\n\nWhen python is built with memory sanitizer enabled, reading any data returned by `os.getrandom()` will trigger a memory sanitizer false positive, because the buffer is filled using a syscall, and the memory isn't marked as having been written to.\n\nCurrently, \n```\n$ cat test.py \nimport os\ndata = os.getrandom(32)\nh = data.hex()\nprint(f'h={h}')\n\n$ ./python ./test.py \nUninitialized bytes in memchr at offset 18 inside [0x707000006458, 66)\n==242471==WARNING: MemorySanitizer: use-of-uninitialized-value\n...\nSUMMARY: MemorySanitizer: use-of-uninitialized-value /home/peter/dev/pvanvugt-cpython/Objects/stringlib/fastsearch.h:58:13 in ucs1lib_find_char\nExiting\n```\n\nI have verified that applying `__masan_unpoison()` to the data fixes this.\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-148851\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/petervanvugt","@type":"Person","name":"petervanvugt"},"datePublished":"2026-04-21T19:01:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/148850/cpython/issues/148850"}
| 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:03bfeff7-3a06-14a1-76fa-672c2d3f4585 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D278:246FC8:268D7E:35DD9D:6A533490 |
| html-safe-nonce | 768d77ee477442f620e0c40267d47cad62127ce66c356dfb71392e13a97e964f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjc4OjI0NkZDODoyNjhEN0U6MzVERDlEOjZBNTMzNDkwIiwidmlzaXRvcl9pZCI6Ijg3MDA4NDM5NzIzNTUxMTAwMzMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 80286fe9cb3dbd7b323e8d201cf1ca4fc0879b14d16d4bd3022eff85a4366f82 |
| hovercard-subject-tag | issue:4304724642 |
| 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/148850/issue_layout |
| twitter:image | https://opengraph.githubassets.com/65e7b7b643e3cda8e99ce93e9aa690f4e6d43146e078af0d2be4704a196807fc/python/cpython/issues/148850 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/65e7b7b643e3cda8e99ce93e9aa690f4e6d43146e078af0d2be4704a196807fc/python/cpython/issues/148850 |
| og:image:alt | Bug report Bug description: When python is built with memory sanitizer enabled, reading any data returned by os.getrandom() will trigger a memory sanitizer false positive, because the buffer is fil... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | petervanvugt |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| 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 | 07a982c1d40157c619b364352b704c3ce66bb332 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width