Title: [WIP] Wire WASI p2 sockets and prepare preview1 descriptor adapters by youknowone · Pull Request #9889 · RustPython/RustPython · GitHub
Open Graph Title: [WIP] Wire WASI p2 sockets and prepare preview1 descriptor adapters by youknowone · Pull Request #9889 · RustPython/RustPython
X Title: [WIP] Wire WASI p2 sockets and prepare preview1 descriptor adapters by youknowone · Pull Request #9889 · RustPython/RustPython
Description: Scope Work in progress for #9867, not ready to merge and not completion of that issue. Route WASI p2 with host_env and without threading through the common Python socket.rs, using socket2/wasi-libc rather than Linux placeholder constants. Threaded p2 selects the fail-closed socket shim. The root interpreter enables threading by default, so its default configuration does not expose the working p2 socket backend. The focused runtime tests below used a non-threading configuration. A compile-time check rejects embeddings that enable rustpython-vm/threading through Cargo feature unification without also enabling rustpython-stdlib/threading. Add a p2 resolver adapter with owned result lifetimes, checked address layout, and preservation of EAI_SYSTEM's original errno. Apply getaddrinfo-specific NUL handling separately from address/getnameinfo validation. Preserve import-only, fail-closed behavior where no Python socket backend is enabled. Do not fabricate descriptor 0, addresses, options, or successful OS operations. Prepare preview1 standard socket imports, descriptor ownership, raw errno retry predicates, and a host-monotonic absolute deadline. Accepted descriptors are closed on validation/range failures. Match CPython 3.15.2 timeout conversion/error ordering on p2 and check deadline addition instead of panicking on overflow. Omit unavailable optional p2 APIs instead of synthesizing legacy aliases, h_errno, or socket duplication. Verified Safety-gate commit e399a6724: p2 stdlib host_env cargo check passed (3m03s), host_env,threading shim check passed (1m28s), and host_env,rustpython-vm/threading intentionally failed with the explicit E0080 safety guard. These are configuration/compilation checks, not threaded runtime support. Earlier runtime results below predate the safety-gate commit. Actual p2 RustPython interpreter linked and ran under Rust 1.99 / Wasmtime 50.0.1 after adding the official wasi-sdk 34 p2 signal-emulation archive. Link validation used cargo rustc with the matching -L/-l arguments to reuse checked dependencies; a clean rebuild using the committed target configuration has not run. Additional actual Python paths passed: delayed TCP read timeout/retry; UDP bind/sendto/recvfrom/nonblocking reads; select readiness and timeout; listen/accept, fd adoption, detach and single-owner close. These do not establish concurrent descriptor safety. Numeric IPv4/IPv6 getnameinfo was also checked through the actual Python interpreter and preserved the pinned SDK's ENOTSUP (58). Python TCP integration passed: connect, sendall, short reads, EOF, shutdown, peer address, close and timeout conversion/error ordering. The same private probe passed CPython 3.15.2 first. Actual Python synchronous signal custom-handler/ignore/restore checks passed. This does not imply asynchronous OS signal delivery. Without runtime network grants, socket creation raised PermissionError (errno 2), and name lookup raised gaierror (-4). No successful operation was fabricated; bind itself was not reached in that denial run. Unknown-WASM stdlib check now passed with rustpython-vm/host_io,getrandom/wasm_js after fixing two socket-shim exception upcasts. This is compilation coverage only, not browser execution or proof of no-JS compatibility. Final p2 common backend: cargo check -p rustpython-stdlib --target wasm32-wasip2 --no-default-features --features host_env --offline -j1 passed. Actual repository DNS adapter under Rust 1.99 / Wasmtime 50.0.1: 3 focused tests passed (numeric IPv4/IPv6 resolution, strict shared NUL contract, and preservation of the SDK's getnameinfo ENOTSUP error). These are adapter tests, not integrated Python tests. Actual preview1 import adapter under Wasmtime 36.0.20 legacy preview1: 14 focused checks passed, including short-read echo/EOF, nonblocking EAGAIN, timeout/deadline and descriptor ownership. WASM import fault injection verified monotonic clock failures, repeated EINTR deadline expiry, and close-on-error for invalid accepted descriptors. Normal rustfmt, spelling and merge-conflict commit hooks passed. Important runtime limitations Wasmtime 50 requires allow-ip-name-lookup for the tested libc resolution path. Network inheritance alone was insufficient. Denials are propagated, not bypassed. The tested Rust 1.99 bundled wasi-libc returns EAI_SYSTEM / ENOTSUP (58) from getnameinfo even with numeric flags. The adapter preserves this error; the initial optimistic round-trip test failed and was replaced by separate resolution and explicit unsupported-operation checks. Lent preview1 sockets were verified only on Wasmtime 36's legacy backend. Wasmtime 50 no longer supports that legacy mode. Wasmer lent-descriptor support is still unverified. The full preview1 Python/backend/host-resource-table integration is still missing. The Python p1 shim remains fail-closed. Preopen inventory must also handle holes before lazy initialization. Threaded p2 sockets are deliberately disabled until descriptor lifetime safety is established. The common raw-fd snapshot can race close/reuse; a PySocket-only Arc or generation number cannot cover detach/adopt or external fd-close aliases. Host-reentrant use is also not established. Verification so far is non-threading. Arbitrary-byte hostname/IDNA parity still needs work. Not yet verified Full Python socket test suite, browser/no-JS integration, full p1 runtime integration and threaded execution. Only the focused end-to-end p2 TCP/signal/capability paths described above have run. Native workspace tests, C-API tests, Clippy and performance measurements have not run. Existing WASI warnings remain. CI must be checked against the new head; no CI or CPython-parity completion is claimed. AI assistance: implementation, investigation and review by OpenAI GPT-6.1 under maintainer direction.
Open Graph Description: Scope Work in progress for #9867, not ready to merge and not completion of that issue. Route WASI p2 with host_env and without threading through the common Python socket.rs, using socket2/wasi-lib...
X Description: Scope Work in progress for #9867, not ready to merge and not completion of that issue. Route WASI p2 with host_env and without threading through the common Python socket.rs, using socket2/wasi-lib...
Opengraph URL: https://github.com/RustPython/RustPython/pull/9889
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,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/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:1f1f16f6-3825-0719-6bd4-538ebcebdf3d |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | B820:1F2B:DB2F0D:125365C:6B01D7EF |
| html-safe-nonce | a63e93403c7bee80551cf99b4be9163b0df3aa84d5a26f683e4418f4de801a79 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCODIwOjFGMkI6REIyRjBEOjEyNTM2NUM6NkIwMUQ3RUYiLCJ2aXNpdG9yX2lkIjoiNzQ3NzY5ODYyMjg5MzcwOTI5NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e6cc7cbf82a08266a53077845d8425ce93a3c975dac51257a11b4277b72cf728 |
| hovercard-subject-tag | pull_request:5338311167 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/RustPython/RustPython/pull/9889/files |
| twitter:image | https://avatars.githubusercontent.com/u/69878?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/69878?s=400&v=4 |
| og:image:alt | Scope Work in progress for #9867, not ready to merge and not completion of that issue. Route WASI p2 with host_env and without threading through the common Python socket.rs, using socket2/wasi-lib... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width