René's URL Explorer Experiment


Title: android (bionic): interpreter genesis aborts with "out of TLS keys" — StaticCell thread_local! statics exhaust PTHREAD_KEYS_MAX · Issue #9084 · RustPython/RustPython · GitHub

Open Graph Title: android (bionic): interpreter genesis aborts with "out of TLS keys" — StaticCell thread_local! statics exhaust PTHREAD_KEYS_MAX · Issue #9084 · RustPython/RustPython

X Title: android (bionic): interpreter genesis aborts with "out of TLS keys" — StaticCell thread_local! statics exhaust PTHREAD_KEYS_MAX · Issue #9084 · RustPython/RustPython

Description: A Python Interpreter written in Rust. Contribute to RustPython/RustPython development by creating an account on GitHub.

Open Graph Description: A Python Interpreter written in Rust. Contribute to RustPython/RustPython development by creating an account on GitHub.

X Description: A Python Interpreter written in Rust. Contribute to RustPython/RustPython development by creating an account on GitHub.

Opengraph URL: https://github.com/RustPython/RustPython

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"android (bionic): interpreter genesis aborts with \"out of TLS keys\" — StaticCell thread_local! statics exhaust PTHREAD_KEYS_MAX","articleBody":"---\nname: Report bugs\nabout: Report a bug not related to CPython compatibility\ntitle: 'android (bionic): interpreter genesis aborts with \"out of TLS keys\" — StaticCell thread_local! statics exhaust PTHREAD_KEYS_MAX'\nlabels: C-bug\nassignees: ''\n---\n\n## Summary\n\nEmbedding `rustpython-vm` on **android (aarch64, bionic libc)** without the `threading` feature aborts during interpreter genesis with:\n\n```text\nfatal runtime error: out of TLS keys, aborting\n```\n\nRoot cause: `StaticCell`'s non-threading variant is backed by `thread_local!` statics (`LocalKey\u003cOnceCell\u003c...>>`). On bionic, **each `thread_local!` static with a destructor consumes one process-wide `pthread_key_t`**, and the pool is capped at `PTHREAD_KEYS_MAX = 1024` (shared with every other TLS user in the process, including std and third-party crates).\n\n`rustpython-vm` instantiates a `StaticCell` slot per builtin type / exception slot / codec slot via the `static_cell!` macro — on the order of **hundreds of `thread_local!` statics** across `crates/vm/src` (11 files contain `static_cell!` invocations; `vm/context.rs`, `exception.rs` and the stdlib modules are the big ones). Genesis initializes all of them at once, blowing through the bionic key pool before startup completes. In a real app (game engine embedding), other TLS consumers push the pool close to the limit even before genesis.\n\n## Expected\n\nInterpreter genesis completes on android (no-threading configuration), as it does on desktop platforms.\n\n## Actual\n\nGenesis aborts during builtin-type initialization:\n\n```text\nfatal runtime error: out of TLS keys, aborting\n```\n\n## Environment\n\n- `aarch64-linux-android` (bionic), NDK r27+, `default-features = false`, features: `compiler, wasmbind, gc, stdio, importlib, encodings, freeze-stdlib` (no `threading`, no `host_env`)\n- Verified against current `main`: `crates/common/src/static_cell.rs` non-threading variant is still `LocalKey\u003cOnceCell\u003c...>>`-based (no android-specific branch)\n- Observed on: RustPython main snapshot 2026-09-22 (`0.6.0-dev`), and re-verified the unfixed state on current `main`\n\n## Analysis\n\n- Bionic (unlike glibc/musl desktop libs, and unlike macOS/Windows TLS implementations rust uses elsewhere) allocates a `pthread_key_t` **per `thread_local!` static with a destructor**, from a **process-wide pool of 1024** (`PTHREAD_KEYS_MAX`).\n- Every `static_cell!` slot in `rustpython-vm` is exactly such a static. Genesis (`Context::init_genesis` + stdlib init) touches all of them in one go.\n- A real application adds its own TLS consumers (std, codecs, GL/math crates), so the effective headroom is smaller than 1024.\n\n## Workaround we shipped (for context — not proposed as a direct patch)\n\nWe added an android-cfg variant of `StaticCell` in our vendored copy: a process-global `UnsafeCell\u003cOnceCell\u003cT>>` + `unsafe impl Sync`, selected via\n`#[cfg(all(not(feature = \"threading\"), feature = \"std\", target_os = \"android\"))]`.\n\nThis is safe under our embedding contract (GIL single-thread, one interpreter per process, always driven on the same thread), and genesis + full gameplay now run cleanly on android (aarch64 real device, HarmonyOS NEXT + 卓易通 container).\n\n**Caveat**: the global-cell approach relies on that single-thread contract and is **not thread-compatible** — we don't propose it as a direct upstream patch. Upstream would need a thread-compatible design (e.g., one TLS slot holding a registry of all `StaticCell`s, instead of one slot per cell).\n\n## Suggested directions\n\n1. A key-frugal `StaticCell` for platforms with small pthread key pools (single TLS slot holding a registry/table of cells), selected by cfg on `target_os = \"android\"`;\n2. Or documenting the android TLS constraint for embedders (no-threading builds abort at genesis once the type count is large enough).\n\nHappy to provide more details, test results, or validate a fix on our android test devices.\n\n## Python Documentation\n\nNot applicable — this is a runtime/embedding issue, not a CPython compatibility issue.\n","author":{"url":"https://github.com/GuYeying","@type":"Person","name":"GuYeying"},"datePublished":"2026-10-11T14:27:46Z","url":"https://github.com/RustPython/RustPython/issues/9084"}

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/:user_id/:repository/issues/:id(.:format)
route-controllerissues
route-actionshow
fetch-noncev2:e28999e2-8ba4-022e-fa8a-fc7c196cdc4f
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idD5CA:172B92:2D44156:3C55E99:6B01D413
html-safe-noncef55e8f06418ce49bf4b868aea450f72e28cabc3a7bd3eb15d51a8ad7618039db
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENUNBOjE3MkI5MjoyRDQ0MTU2OjNDNTVFOTk6NkIwMUQ0MTMiLCJ2aXNpdG9yX2lkIjoiNjQ4ODUzMzMzNzgzNjIxMzI2NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac577920eaa6d02d12f3ab506142630ba8c6fe3794735a3c8fe25540e49525cc42
hovercard-subject-tagrepository:135201145
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///issues/show
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/RustPython/RustPython/issues/9084
twitter:imagehttps://opengraph.githubassets.com/8b6bc91d3baaf62a969a0721494e51d7c08f420d61d44b393656cebdf755eb84/RustPython/RustPython
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/8b6bc91d3baaf62a969a0721494e51d7c08f420d61d44b393656cebdf755eb84/RustPython/RustPython
og:image:altA Python Interpreter written in Rust. Contribute to RustPython/RustPython development by creating an account on GitHub.
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
Nonecc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c
turbo-cache-controlno-cache
go-importgithub.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git
octolytics-dimension-user_id39710557
octolytics-dimension-user_loginRustPython
octolytics-dimension-repository_id135201145
octolytics-dimension-repository_nwoRustPython/RustPython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id135201145
octolytics-dimension-repository_network_root_nwoRustPython/RustPython
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
release8c77c9e8439031ad54c75a250694842892f693e1
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/RustPython/RustPython/issues/9084#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FRustPython%2FRustPython%2Fissues%2F9084
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%2FRustPython%2FRustPython%2Fissues%2F9084
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fissues%2Fshow&source=header-repo&source_repo=RustPython%2FRustPython
Reloadhttps://github.com/RustPython/RustPython/issues/9084
Reloadhttps://github.com/RustPython/RustPython/issues/9084
Reloadhttps://github.com/RustPython/RustPython/issues/9084
https://github.com/RustPython/RustPython
New issuehttps://github.com/login?return_to=https://github.com/RustPython/RustPython/issues/9084
New issuehttps://github.com/login?return_to=https://github.com/RustPython/RustPython/issues/9084
android (bionic): interpreter genesis aborts with "out of TLS keys" — StaticCell thread_local! statics exhaust PTHREAD_KEYS_MAXhttps://github.com/RustPython/RustPython/issues/9084#top
https://github.com/GuYeying
GuYeyinghttps://github.com/GuYeying
on Oct 11, 2026https://github.com/RustPython/RustPython/issues/9084#issue-5801956441
Sign up for freehttps://github.com/signup?return_to=https://github.com/RustPython/RustPython/issues/9084
Sign in to commenthttps://github.com/login?return_to=https://github.com/RustPython/RustPython/issues/9084
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.