René's URL Explorer Experiment


Title: [macOS x86_64, python >= 3.14] Process hangs when importing ctypes from embedded interpreter in a x86_64 macOS executable with enabled hardened runtime · Issue #160627 · python/cpython · GitHub

Open Graph Title: [macOS x86_64, python >= 3.14] Process hangs when importing ctypes from embedded interpreter in a x86_64 macOS executable with enabled hardened runtime · Issue #160627 · python/cpython

X Title: [macOS x86_64, python >= 3.14] Process hangs when importing ctypes from embedded interpreter in a x86_64 macOS executable with enabled hardened runtime · Issue #160627 · python/cpython

Description: The addition of early ffi_closure_alloc() call to execution/initialization of the _ctypes extension in python 3.14.0 (04d4aac / #131633) has exacerbated the problem that embedders (such as PyInstaller) encounter on macOS with x86_64 exec...

Open Graph Description: The addition of early ffi_closure_alloc() call to execution/initialization of the _ctypes extension in python 3.14.0 (04d4aac / #131633) has exacerbated the problem that embedders (such as PyInstal...

X Description: The addition of early ffi_closure_alloc() call to execution/initialization of the _ctypes extension in python 3.14.0 (04d4aac / #131633) has exacerbated the problem that embedders (such as PyInstal...

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

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[macOS x86_64, python >= 3.14] Process hangs when importing ctypes from embedded interpreter in a x86_64 macOS executable with enabled hardened runtime","articleBody":"The addition of early [`ffi_closure_alloc()` call to execution/initialization of the `_ctypes` extension](https://github.com/python/cpython/blob/v3.14.8/Modules/_ctypes/_ctypes.c#L6398) in python 3.14.0 (https://github.com/python/cpython/commit/04d4aacaacbe26146e9b5ff6b0043f86f3c543d4 / https://github.com/python/cpython/pull/131633) has exacerbated the problem that embedders (such as PyInstaller) encounter on macOS with x86_64 executables that have been codesigned with enabled hardened runtime (which is a requirement for app notarization in Apple Store).\n\nNamely, when such executable (running either natively on an intel Mac, or under Rosetta on an arm64 Mac) ends up calling `ffi_closure_alloc()`, the process hangs, and the system log shows continuous stream of error messages like this one:\n\n``` \n2026-10-20 09:48:59.486398-0700 0x6afb Error 0x0 0 0 kernel: (AppleMobileFileIntegrity) Library Validation failed: Rejecting '/private/var/folders/7c/49675rcx2nb0lwjms_6wmdpr0000gs/T/ffiiyZPuH' (Team ID: none, platform: no) for process 'dangerzone(3322)' (Team ID: 94ZZGGGJ3W, platform: no), reason: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.\n```\n\nAt PyInstaller, we've previously observed this issue with python packages that use `cffi` (e.g., `PyOpenSSL` in https://github.com/pyinstaller/pyinstaller/issues/8099); and presumably it would also happen with code that uses `ctypes` and ends up in a codepath that ends up calling `ffi_closure_alloc`, for example in `PyCFuncPtr_new`. \n\nThe issue does not affect arm64 executables, and the work-around for x86_64 is to enable `com.apple.security.cs.allow-unsigned-executable-memory` entitlement when signing the executable / app bundle.\n\nWe have now received a report of it happening simply by switching from python 3.13 to 3.14 (https://github.com/pyinstaller/pyinstaller/issues/9554). I've traced the problem to import of `ctypes` (and subsequently the afore-mentioned early `ffi_closure_alloc()` call in `_ctypes`), which happens during bootstrap phase of a PyInstaller-frozen python application; so it is guaranteed to happen with python >= 3.14 and with hardened runtime enabled, regardless of how `ctypes` is actually used, and requires the entitlement as a work-around.\n\nThe true cause of the problem is a bug in `libffi`; in x86_64 codepath it tries to `mmap` an empty temporary file with `PROT_EXEC`, which fails due to hardened runtime and file not being signed, and leads to an endless retry loop - see https://github.com/libffi/libffi/issues/1032.\n\nSo strictly speaking, this is not a bug in CPython. However, in the grander scheme of things, with Apple dropping support for Intel Macs, even if `libffi` fixes the problem on their side, the remaining Intel Macs are unlikely to see the fix; the official python builds from python.org seem to be using system-provided copy of `libffi` (`/usr/lib/libffi.dylib`, which would have to be updated by Apple), and both Homebrew and Anaconda have also dropped support for x86_64 on macOS.\n\nAs https://github.com/python/cpython/pull/131633 seems to have been trying to address an issue in free-threaded python builds (https://github.com/python/cpython/issues/128485), I was wondering if it would be possible to put the early `ffi_closure_alloc` call under ifdefs so that it is omitted for regular (non-free-threaded) python builds on x86_64 macOS? This would mitigate the issue for embedders who still want to support Intel Macs and use latest versions of python. If it is not possible (or worth the hassle), then hopefully this issue report can nudge them in the right direction with the entitlement-based work-around.","author":{"url":"https://github.com/rokm","@type":"Person","name":"rokm"},"datePublished":"2026-10-24T22:37:39Z","url":"https://github.com/python/cpython/issues/160627"}

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:f0138864-38c3-cfee-9d64-f2a06cafe512
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idB156:380435:9775AA:BF0657:6B021B6F
html-safe-nonce840357bd8efbc7bbdf1510123db55c3ceacebf5e1ec2f863a9e674aba6c50727
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMTU2OjM4MDQzNTo5Nzc1QUE6QkYwNjU3OjZCMDIxQjZGIiwidmlzaXRvcl9pZCI6IjcwMjQzNTI5ODc4NzEwNTg3OTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmaca27d662146744df03be1c0194cb5a4cd1c7c6716797dcc37b7f8725307022704
hovercard-subject-tagissue:6018363715
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/160627/issue_layout
twitter:imagehttps://opengraph.githubassets.com/f0b0e61da8fdddd697903c2612188d735ca4fbfc4a830fe0d5f00b4f7f46a419/python/cpython/issues/160627
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/f0b0e61da8fdddd697903c2612188d735ca4fbfc4a830fe0d5f00b4f7f46a419/python/cpython/issues/160627
og:image:altThe addition of early ffi_closure_alloc() call to execution/initialization of the _ctypes extension in python 3.14.0 (04d4aac / #131633) has exacerbated the problem that embedders (such as PyInstal...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamerokm
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/160627#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fissues%2F160627
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%2F160627
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/160627
Reloadhttps://github.com/python/cpython/issues/160627
Reloadhttps://github.com/python/cpython/issues/160627
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/160627
New issuehttps://github.com/login?return_to=https://github.com/python/cpython/issues/160627
[macOS x86_64, python >= 3.14] Process hangs when importing ctypes from embedded interpreter in a x86_64 macOS executable with enabled hardened runtimehttps://github.com/python/cpython/issues/160627#top
OS-machttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-mac%22
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
topic-ctypeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-ctypes%22
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
https://github.com/rokm
rokmhttps://github.com/rokm
on Oct 24, 2026https://github.com/python/cpython/issues/160627#issue-6018363715
ffi_closure_alloc() call to execution/initialization of the _ctypes extensionhttps://github.com/python/cpython/blob/v3.14.8/Modules/_ctypes/_ctypes.c#L6398
04d4aachttps://github.com/python/cpython/commit/04d4aacaacbe26146e9b5ff6b0043f86f3c543d4
#131633https://github.com/python/cpython/pull/131633
pyinstaller/pyinstaller#8099https://github.com/pyinstaller/pyinstaller/issues/8099
pyinstaller/pyinstaller#9554https://github.com/pyinstaller/pyinstaller/issues/9554
libffi/libffi#1032https://github.com/libffi/libffi/issues/1032
#131633https://github.com/python/cpython/pull/131633
#128485https://github.com/python/cpython/issues/128485
NekoAsakurahttps://github.com/NekoAsakura
type-bugAn unexpected behavior, bug, or errorhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22type-bug%22
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
OS-machttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-mac%22
topic-ctypeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-ctypes%22
on Oct 25, 2026https://github.com/python/cpython/issues/160627#event-34156848171
https://github.com/apyrgio
apyrgiohttps://github.com/apyrgio
on Oct 27, 2026https://github.com/python/cpython/issues/160627#issuecomment-6443986560
#135893https://github.com/python/cpython/issues/135893
https://github.com/ZeroIntensity
ZeroIntensityhttps://github.com/ZeroIntensity
on Nov 12, 2026https://github.com/python/cpython/issues/160627#issuecomment-6811877914
#135893https://github.com/python/cpython/issues/135893
ZeroIntensityhttps://github.com/ZeroIntensity
duplicatehttps://github.com/python/cpython/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Aduplicate
Importing ctypes results in extra open libffi file descriptor since 3.14 #135893https://github.com/python/cpython/issues/135893
on Nov 12, 2026https://github.com/python/cpython/issues/160627#event-35862437802
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/cpython/issues/160627
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/cpython/issues/160627
OS-machttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22OS-mac%22
extension-modulesC modules in the Modules dirhttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22extension-modules%22
topic-ctypeshttps://github.com/python/cpython/issues?q=state%3Aopen%20label%3A%22topic-ctypes%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.