René's URL Explorer Experiment


Title: Concurrent compilation changes marshal output in free-threaded builds · Issue #156504 · python/cpython · GitHub

Open Graph Title: Concurrent compilation changes marshal output in free-threaded builds · Issue #156504 · python/cpython

X Title: Concurrent compilation changes marshal output in free-threaded builds · Issue #156504 · python/cpython

Description: Bug description: Concurrent compilation on free-threaded CPython builds can produce marshal output that differs byte-for-byte from serial compilation of the same source. This occurs both with the GIL disabled and with the GIL explicitly ...

Open Graph Description: Bug description: Concurrent compilation on free-threaded CPython builds can produce marshal output that differs byte-for-byte from serial compilation of the same source. This occurs both with the G...

X Description: Bug description: Concurrent compilation on free-threaded CPython builds can produce marshal output that differs byte-for-byte from serial compilation of the same source. This occurs both with the G...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Concurrent compilation changes marshal output in free-threaded builds","articleBody":"### Bug description:\n\nConcurrent compilation on free-threaded CPython builds can produce marshal output that differs byte-for-byte from serial compilation of the same source.\n\nThis occurs both with the GIL disabled and with the GIL explicitly re-enabled. It reproduces on Windows and Linux/WSL. Standard CPython builds used as controls did not reproduce the difference.\n\nThis was discovered while implementing threaded bytecode compilation in [pypa/pip#14286](https://github.com/pypa/pip/pull/14286).\n\n## Reproducer\n\nA standalone standard-library-only reproducer is available here:\n\n- [Reproducer script](https://github.com/khmyznikov/pip/blob/review/windows-bytecode-threads/tools/repro_threaded_pyc_determinism.py)\n- [Methodology and results](https://github.com/khmyznikov/pip/blob/review/windows-bytecode-threads/tools/repro_threaded_pyc_determinism.md)\n\nIt does not import or execute pip. It:\n\n- creates 64 copies of a minimized source fixture;\n- compiles corresponding files serially and with a `ThreadPoolExecutor`, in fresh child interpreters;\n- fixes logical filenames, `PYTHONHASHSEED`, and `SOURCE_DATE_EPOCH`;\n- compares checked-hash `.pyc` files or raw `marshal.dumps(compile(...))` payloads;\n- unmarshals differing outputs and recursively compares documented code-object fields.\n\nExample using the raw marshal backend:\n\n```console\npython3.14t repro_threaded_pyc_determinism.py --gil off --backend marshal --workers 4 --output repro-ft-off-marshal --require-difference\npython3.14t repro_threaded_pyc_determinism.py --gil on --backend marshal --workers 4 --output repro-ft-on-marshal --require-difference\n```\n\nThe output directory must be new or empty.\n\n## Expected behavior\n\nSerial and concurrent compilation of the same source, using the same logical filename and deterministic environment settings, should produce byte-identical marshal output.\n\n## Actual behavior\n\nOn free-threaded builds, some concurrently compiled files have different serialized bytes from their serial counterparts.\n\nThe differing payloads have:\n\n- equal lengths;\n- equal `.pyc` headers when using `py_compile`;\n- equal values for all recursively inspected code-object fields after unmarshalling, including bytecode, constants, names, filenames, line tables, exception tables, and nested code objects.\n\nThe raw marshal backend reproduces the behavior without `py_compile` or `.pyc` headers. Its differing offsets are exactly 16 bytes earlier than the corresponding `.pyc` offsets, confirming that the `.pyc` header is not responsible.\n\nAn empty `semanticDifferences` result does not establish that the object identity or alias graph is identical. The precise cause has not yet been determined.\n\n## Observed results\n\n### Windows\n\nWindows 11 prerelease VM, eight virtual CPUs, CPython 3.15.0rc1 free-threaded build and corresponding standard CPython 3.15 build:\n\n| Build | GIL | Backend | Result |\n| --- | --- | --- | --- |\n| Free-threaded | Off | `py_compile` | Reproduced; 49 differing bytes in a 3,447-byte `.pyc` |\n| Free-threaded | On | `py_compile` | Reproduced; 49 differing bytes in a 3,447-byte `.pyc` |\n| Free-threaded | Off | `marshal` | Reproduced; 49 differing bytes in a 3,431-byte payload |\n| Free-threaded | On | `marshal` | Reproduced; 49 differing bytes in a 3,431-byte payload |\n| Standard | On/default | Both | No difference in 10 attempts |\n\n### Linux under WSL2\n\nUbuntu 26.04 LTS, kernel `6.18.33.2-microsoft-standard-WSL2`, native ext4 storage, four available CPUs:\n\n| Build | GIL | Backend | Result |\n| --- | --- | --- | --- |\n| CPython 3.14.7 free-threaded | Off | `py_compile` | Reproduced on attempt 1 |\n| CPython 3.14.7 free-threaded | On | `py_compile` | Reproduced on attempt 1 |\n| CPython 3.14.7 free-threaded | Off | `marshal` | Reproduced on attempt 1 |\n| CPython 3.14.7 free-threaded | On | `marshal` | Reproduced on attempt 1 |\n| CPython 3.14.4 standard | On/default | Both | No difference in 10 attempts |\n\nThe WSL differences contained 50 differing bytes per output. All inspected decoded code-object field values were equal.\n\n## Impact\n\nAlthough the decoded code objects appear semantically equivalent, byte-different outputs affect:\n\n- reproducible builds;\n- artifact hashing;\n- build caches;\n- deterministic CI output;\n- tools that record `.pyc` hashes.\n\nRe-enabling the GIL on a free-threaded build does not prevent the behavior. As a temporary precaution, pip’s proposed threaded compilation path detects `Py_GIL_DISABLED` at build time and remains serial for free-threaded builds.\n\n### CPython versions tested on:\n\n3.15\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-156862\n* gh-159192\n* gh-159290\n\u003c!-- /gh-linked-prs -->","author":{"url":"https://github.com/khmyznikov","@type":"Person","name":"khmyznikov"},"datePublished":"2026-08-27T23:02:22Z","url":"https://github.com/python/cpython/issues/156504"}

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:56acc3c0-0cbe-ca16-8dde-06ca98814ee1
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEABC:2270F4:377E0E4:4992087:6B020AD9
html-safe-nonced55038b038458fa2a7abb7a1d34038f44e5e69c704d1eff45f255fda1564bb64
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFQUJDOjIyNzBGNDozNzdFMEU0OjQ5OTIwODc6NkIwMjBBRDkiLCJ2aXNpdG9yX2lkIjoiMzIxMDU5MjQ4NzY4NTA5ODIwMSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmace7427c222933f168ff8a38db5fc2c498a0f7c6a183508ea7474a7319ac0fcd9e
hovercard-subject-tagissue:5272910191
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/156504/issue_layout
twitter:imagehttps://opengraph.githubassets.com/73377fcc07c8111c430297c304f828c7073be1f1bca6b68901457742618d41ca/python/cpython/issues/156504
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/73377fcc07c8111c430297c304f828c7073be1f1bca6b68901457742618d41ca/python/cpython/issues/156504
og:image:altBug description: Concurrent compilation on free-threaded CPython builds can produce marshal output that differs byte-for-byte from serial compilation of the same source. This occurs both with the G...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamekhmyznikov
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/156504#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F156504
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%2F156504
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/156504
Reloadhttps://github.com/python/cpython/issues/156504
Reloadhttps://github.com/python/cpython/issues/156504
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/156504
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/156504
#159192https://github.com/python/cpython/pull/159192
Concurrent compilation changes marshal output in free-threaded buildshttps://github.com/python/cpython/issues/156504#top
#159192https://github.com/python/cpython/pull/159192
https://github.com/gpshead
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/khmyznikov
khmyznikovhttps://github.com/khmyznikov
on Aug 27, 2026https://github.com/python/cpython/issues/156504#issue-5272910191
pypa/pip#14286https://github.com/pypa/pip/pull/14286
Reproducer scripthttps://github.com/khmyznikov/pip/blob/review/windows-bytecode-threads/tools/repro_threaded_pyc_determinism.py
Methodology and resultshttps://github.com/khmyznikov/pip/blob/review/windows-bytecode-threads/tools/repro_threaded_pyc_determinism.md
gh-129724: Make marshalled code output deterministic #156862https://github.com/python/cpython/pull/156862
gh-129724: gh-156504: Make marshal output independent of reference counts #159192https://github.com/python/cpython/pull/159192
[3.15] gh-129724: gh-156504: Make marshal output independent of reference counts (GH-159192) #159290https://github.com/python/cpython/pull/159290
khmyznikovhttps://github.com/khmyznikov
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
on Aug 27, 2026https://github.com/python/cpython/issues/156504#event-30135010706
aiskhttps://github.com/aisk
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%22
on Aug 28, 2026https://github.com/python/cpython/issues/156504#event-30139031105
ZeroIntensityhttps://github.com/ZeroIntensity
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
on Aug 28, 2026https://github.com/python/cpython/issues/156504#event-30171708386
https://github.com/SurbhiAgarwal1
SurbhiAgarwal1https://github.com/SurbhiAgarwal1
on Aug 29, 2026https://github.com/python/cpython/issues/156504#issuecomment-5464693426
@khmyznikovhttps://github.com/khmyznikov
[marshal.c](https://github.com/python/cpython/blob/main/Python/marshal.c)https://github.com/python/cpython/blob/main/Python/marshal.c
[pycore_object.h](https://github.com/python/cpython/blob/main/Include/internal/pycore_object.h)https://github.com/python/cpython/blob/main/Include/internal/pycore_object.h
https://github.com/dylanpulver
dylanpulverhttps://github.com/dylanpulver
on Aug 31, 2026https://github.com/python/cpython/issues/156504#issuecomment-5477430939
@SurbhiAgarwal1https://github.com/SurbhiAgarwal1
gpsheadhttps://github.com/gpshead
on Oct 11, 2026https://github.com/python/cpython/issues/156504#event-32996919034
gpsheadhttps://github.com/gpshead
on Oct 11, 2026https://github.com/python/cpython/issues/156504#event-33005610942
pythongh-129724: Make marshal output independent of reference countshttps://github.com/gpshead/cpython/commit/78939500b81313474d6030da0cb4f3fdc516553e
pythongh-129724https://github.com/python/cpython/issues/129724
7893950https://github.com/gpshead/cpython/commit/78939500b81313474d6030da0cb4f3fdc516553e
pythongh-129724: Make marshal output independent of reference countshttps://github.com/gpshead/cpython/commit/6ee27e06af58575cebdb2a998ce239497c2e996a
pythongh-129724https://github.com/python/cpython/issues/129724
6ee27e0https://github.com/gpshead/cpython/commit/6ee27e06af58575cebdb2a998ce239497c2e996a
Merge the pythongh-156504 NEWS entry into the pythongh-129724 onehttps://github.com/gpshead/cpython/commit/d69021ed3d5b4dad860e32d15c1e53ca8b54b3ac
pythongh-156504https://github.com/python/cpython/issues/156504
pythongh-129724https://github.com/python/cpython/issues/129724
d69021ehttps://github.com/gpshead/cpython/commit/d69021ed3d5b4dad860e32d15c1e53ca8b54b3ac
gh-129724: gh-156504: Make marshal output independent of reference co…https://github.com/python/cpython/commit/48f18f0adb7ecbde409f56409ef54ccce72ca4c3
gh-129724https://github.com/python/cpython/issues/129724
gh-156504https://github.com/python/cpython/issues/156504
48f18f0https://github.com/python/cpython/commit/48f18f0adb7ecbde409f56409ef54ccce72ca4c3
gpsheadhttps://github.com/gpshead
completedhttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
#159192https://github.com/python/cpython/pull/159192
on Oct 13, 2026https://github.com/python/cpython/issues/156504#event-33101108002
gpsheadhttps://github.com/gpshead
on Oct 24, 2026https://github.com/python/cpython/issues/156504#event-34155559973
[3.15] pythongh-129724: pythongh-156504: Make marshal output independ…https://github.com/gpshead/cpython/commit/8fb8fc3cac793bb66f04a8b58d6eba87402fc7dc
pythongh-129724https://github.com/python/cpython/issues/129724
pythongh-156504https://github.com/python/cpython/issues/156504
8fb8fc3https://github.com/gpshead/cpython/commit/8fb8fc3cac793bb66f04a8b58d6eba87402fc7dc
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/156504
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/156504
gpsheadhttps://github.com/gpshead
interpreter-core(Objects, Python, Grammar, and Parser dirs)https://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22interpreter-core%22
topic-free-threadinghttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-free-threading%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.