René's URL Explorer Experiment


Title: bytes.fromhex() reads uninitialized memory · Issue #158583 · python/cpython · GitHub

Open Graph Title: bytes.fromhex() reads uninitialized memory · Issue #158583 · python/cpython

X Title: bytes.fromhex() reads uninitialized memory · Issue #158583 · python/cpython

Description: Example: import array res = bytes.fromhex(array.array('B', b' 1A 2B 30 ')) try: bytes.fromhex(array.array('B', b' 1A 2B 3')) except ValueError: pass Valgrind reports two "Use of uninitialised value of size 8" errors: $ PYTHONMALLOC=mallo...

Open Graph Description: Example: import array res = bytes.fromhex(array.array('B', b' 1A 2B 30 ')) try: bytes.fromhex(array.array('B', b' 1A 2B 3')) except ValueError: pass Valgrind reports two "Use of uninitialised value...

X Description: Example: import array res = bytes.fromhex(array.array('B', b' 1A 2B 30 ')) try: bytes.fromhex(array.array('B', b' 1A 2B 3')) except ValueError: pass Valgrind reports...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"bytes.fromhex() reads uninitialized memory","articleBody":"Example:\n\n```py\nimport array\nres = bytes.fromhex(array.array('B', b' 1A 2B 30 '))\ntry:\n    bytes.fromhex(array.array('B', b' 1A 2B 3'))\nexcept ValueError:\n    pass\n```\n\nValgrind reports two \"Use of uninitialised value of size 8\" errors:\n\n```\n$ PYTHONMALLOC=malloc valgrind ./python x.py \n==863634== Memcheck, a memory error detector\n==863634== Copyright (C) 2002-2026, and GNU GPL'd, by Julian Seward et al.\n==863634== Using Valgrind-3.27.1 and LibVEX; rerun with -h for copyright info\n==863634== Command: ./python x.py\n==863634== \n==863634== Use of uninitialised value of size 8\n==863634==    at 0x497C07: _PyBytes_FromHex (bytesobject.c:2688)\n==863634==    by 0x497CC2: bytes_fromhex_impl (bytesobject.c:2618)\n==863634==    by 0x497D07: bytes_fromhex (bytesobject.c.h:1261)\n==863634==    by 0x4F491A: cfunction_vectorcall_O (methodobject.c:535)\n==863634==    by 0x49BDAF: _PyObject_VectorcallTstate (pycore_call.h:149)\n==863634==    by 0x49BE77: PyObject_Vectorcall (call.c:327)\n==863634==    by 0x5B0C90: _Py_VectorCallInstrumentation_StackRefSteal (ceval.c:770)\n==863634==    by 0x5B7E1C: _PyEval_EvalFrameDefault (generated_cases.c.h:1906)\n==863634==    by 0x5CFACD: _PyEval_EvalFrame (pycore_ceval.h:122)\n==863634==    by 0x5CFC98: _PyEval_Vector (ceval.c:2176)\n==863634==    by 0x5CFD7C: PyEval_EvalCode (ceval.c:681)\n==863634==    by 0x649C6B: run_eval_code_obj (pythonrun.c:1406)\n==863634== \n==863634== Use of uninitialised value of size 8\n==863634==    at 0x497BC1: _PyBytes_FromHex (bytesobject.c:2700)\n==863634==    by 0x497CC2: bytes_fromhex_impl (bytesobject.c:2618)\n==863634==    by 0x497D07: bytes_fromhex (bytesobject.c.h:1261)\n==863634==    by 0x4F491A: cfunction_vectorcall_O (methodobject.c:535)\n==863634==    by 0x49BDAF: _PyObject_VectorcallTstate (pycore_call.h:149)\n==863634==    by 0x49BE77: PyObject_Vectorcall (call.c:327)\n==863634==    by 0x5B0C90: _Py_VectorCallInstrumentation_StackRefSteal (ceval.c:770)\n==863634==    by 0x5B7E1C: _PyEval_EvalFrameDefault (generated_cases.c.h:1906)\n==863634==    by 0x5CFACD: _PyEval_EvalFrame (pycore_ceval.h:122)\n==863634==    by 0x5CFC98: _PyEval_Vector (ceval.c:2176)\n==863634==    by 0x5CFD7C: PyEval_EvalCode (ceval.c:681)\n==863634==    by 0x649C6B: run_eval_code_obj (pythonrun.c:1406)\n==863634== \n==863634== \n==863634== HEAP SUMMARY:\n==863634==     in use at exit: 1,618 bytes in 4 blocks\n==863634==   total heap usage: 36,249 allocs, 36,245 frees, 9,219,652 bytes allocated\n==863634== \n==863634== LEAK SUMMARY:\n==863634==    definitely lost: 0 bytes in 0 blocks\n==863634==    indirectly lost: 0 bytes in 0 blocks\n==863634==      possibly lost: 0 bytes in 0 blocks\n==863634==    still reachable: 1,618 bytes in 4 blocks\n==863634==         suppressed: 0 bytes in 0 blocks\n==863634== Rerun with --leak-check=full to see details of leaked memory\n==863634== \n==863634== Use --track-origins=yes to see where uninitialised values come from\n==863634== For lists of detected and suppressed errors, rerun with: -s\n==863634== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)\n```\n\nThe problem is in `_PyBytes_FromHex()`: `str++` doesn't check if we reached `end`.\n\nFor example, for a buffer of 10 bytes, it can read the 11th: outside the buffer!\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-158584\n* gh-158691\n* gh-158692\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/vstinner","@type":"Person","name":"vstinner"},"datePublished":"2026-10-01T22:31:01Z","url":"https://github.com/python/cpython/issues/158583"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:45ec56c3-9287-f9d0-d6eb-662b3d474d2d
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idCDAE:2A7C1C:1AC1105:2354259:6B021B31
html-safe-nonce84cb9cb7361653da5a83a67cc072e22d39274db5b190ae97387bf0ff1292a5d7
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDREFFOjJBN0MxQzoxQUMxMTA1OjIzNTQyNTk6NkIwMjFCMzEiLCJ2aXNpdG9yX2lkIjoiMjY2MDE4OTA5NTgwODA4MDY4OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacadae4f309eccb24ad66f1271ef892c3bcac14c272a7488661997cccd27b4a7a6
hovercard-subject-tagissue:5670109685
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/158583/issue_layout
twitter:imagehttps://opengraph.githubassets.com/600cb5ef5d3b5f3b3eff8cb4b0116770b9db4bc40877a9502397183dda78ed6e/python/cpython/issues/158583
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/600cb5ef5d3b5f3b3eff8cb4b0116770b9db4bc40877a9502397183dda78ed6e/python/cpython/issues/158583
og:image:altExample: import array res = bytes.fromhex(array.array('B', b' 1A 2B 30 ')) try: bytes.fromhex(array.array('B', b' 1A 2B 3')) except ValueError: pass Valgrind reports two "Use of uninitialised value...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamevstinner
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
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
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/cpython/issues/158583#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F158583
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
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
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://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
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F158583
Sign uphttps://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/158583
Reloadhttps://github.com/python/cpython/issues/158583
Reloadhttps://github.com/python/cpython/issues/158583
pythonhttps://github.com/python
cpythonhttps://github.com/python/cpython
Codehttps://github.com/python/cpython
Issues5k+ (5k+)https://github.com/python/cpython/issues
Pull requests2.4k (2.4k)https://github.com/python/cpython/pulls
Actionshttps://github.com/python/cpython/actions
Projectshttps://github.com/python/cpython/projects
Security and qualityhttps://github.com/python/cpython/security
Insightshttps://github.com/python/cpython/insights
https://github.com/python/cpython
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/158583
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/158583
bytes.fromhex() reads uninitialized memoryhttps://github.com/python/cpython/issues/158583#top
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Oct 1, 2026https://github.com/python/cpython/issues/158583#issue-5670109685
gh-158583: Fix uninitialized memory read in bytes.fromhex() #158584https://github.com/python/cpython/pull/158584
[3.15] gh-158583: Fix uninitialized memory read in bytes.fromhex() (GH-158584) #158691https://github.com/python/cpython/pull/158691
[3.14] gh-158583: Fix uninitialized memory read in bytes.fromhex() (GH-158584) #158692https://github.com/python/cpython/pull/158692
vstinnerhttps://github.com/vstinner
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
on Oct 1, 2026https://github.com/python/cpython/issues/158583#event-32294070481
vstinnerhttps://github.com/vstinner
on Oct 1, 2026https://github.com/python/cpython/issues/158583#event-32294184286
pythongh-158583: Fix uninitialized memory read in bytes.fromhex()https://github.com/vstinner/cpython/commit/1d3eab6df611e8a21f7aa1767ac2ae548a901226
pythongh-158583https://github.com/python/cpython/issues/158583
1d3eab6https://github.com/vstinner/cpython/commit/1d3eab6df611e8a21f7aa1767ac2ae548a901226
https://github.com/vstinner
vstinnerhttps://github.com/vstinner
on Oct 1, 2026https://github.com/python/cpython/issues/158583#issuecomment-5942215541
e0637cehttps://github.com/python/cpython/commit/e0637cebe5bf863897f2e89dfcb76be0015c1877
vstinnerhttps://github.com/vstinner
on Oct 3, 2026https://github.com/python/cpython/issues/158583#event-32420626002
gh-158583: Fix uninitialized memory read in bytes.fromhex() (#158584)https://github.com/python/cpython/commit/9d22a5334bd5273962adceeb697a1337e9a0ca21
gh-158583https://github.com/python/cpython/issues/158583
#158584https://github.com/python/cpython/pull/158584
9d22a53https://github.com/python/cpython/commit/9d22a5334bd5273962adceeb697a1337e9a0ca21
vstinnerhttps://github.com/vstinner
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Oct 4, 2026https://github.com/python/cpython/issues/158583#event-32421274712
vstinnerhttps://github.com/vstinner
on Oct 4, 2026https://github.com/python/cpython/issues/158583#event-32421397600
[3.14] gh-158583: Fix uninitialized memory read in bytes.fromhex() (G…https://github.com/python/cpython/commit/66df30d15c9052785ed6463663e70d38107a9edf
gh-158583https://github.com/python/cpython/issues/158583
G…https://github.com/python/cpython/pull/158584
66df30dhttps://github.com/python/cpython/commit/66df30d15c9052785ed6463663e70d38107a9edf
pablogsalhttps://github.com/pablogsal
on Oct 5, 2026https://github.com/python/cpython/issues/158583#event-32496616187
[3.15] gh-158583: Fix uninitialized memory read in bytes.fromhex() (G…https://github.com/python/cpython/commit/4f7af46e25f09bf54b6f499c5c40b661786f0d69
gh-158583https://github.com/python/cpython/issues/158583
G…https://github.com/python/cpython/pull/158584
4f7af46https://github.com/python/cpython/commit/4f7af46e25f09bf54b6f499c5c40b661786f0d69
Revert "[3.15] pythongh-158583: Fix uninitialized memory read in byte…https://github.com/pablogsal/cpython/commit/30df3946e19ce6a02e3b80e1662a22538b5212c7
pythongh-158583https://github.com/python/cpython/issues/158583
30df394https://github.com/pablogsal/cpython/commit/30df3946e19ce6a02e3b80e1662a22538b5212c7
[3.15] Restore deferred backports for 3.15.1, including GH-158874 (#1…https://github.com/python/cpython/commit/4ceb3faf2c1f5bf17c56be085c4b1c1b38e47f9e
GH-158874https://github.com/python/cpython/pull/158874
#1…https://github.com/python/cpython/pull/158882
4ceb3fahttps://github.com/python/cpython/commit/4ceb3faf2c1f5bf17c56be085c4b1c1b38e47f9e
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/158583
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/158583
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
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.