vcswatch reports that
this package seems to have new commits in its VCS but has
not yet updated debian/changelog. You should consider updating
the Debian changelog and uploading this new version into the archive.
Here are the relevant commit logs:
commit 373fb0f8183a11517d7bf6a78757ab64ba3e4e21
Author: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Date: Thu Dec 3 17:50:26 2026 +0100
bump version to 0.0~git20260819.2e6fb9d-1
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
commit 33cb6278b4b3f28ec2d44d503b636ce7bb84ff4e
Author: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Date: Thu Dec 3 13:16:17 2026 +0100
switch to LLVM 23
like rustc
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
commit a8684e8c452a683936b67c2cef2b46e79e7e1486
Author: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Date: Fri Nov 27 10:45:38 2026 +0100
add patch to pass `--all-features` to wasm-tools
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
commit c75afe32cb242623431a6a05c94293d5749e1167
Author: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Date: Fri Nov 27 09:55:35 2026 +0100
switch to LLVM 22
we'll switch to 23 once it's in backports, together with rustc..
Closes: #1155408
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
commit 1cf91eb6181e4cda2e5fd25118479768c9ddc18a
Author: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Date: Fri Nov 27 09:50:12 2026 +0100
update changelog for upstream version
Gbp-Dch: ignore
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
commit deac3f0dfcb179aa85b05798c4a4c8413fe7c69b
Merge: bfcb949 5fbaa54
Author: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Date: Fri Nov 27 09:39:14 2026 +0100
Update upstream source from tag 'upstream/0.0_git20260819.2e6fb9d'
Update to upstream version '0.0~git20260819.2e6fb9d'
with Debian dir 08910315d61756bff12b8b0f0f1f1a716c4aafba
commit 5fbaa547348a7ce5e8ae8f1890decee738049b78
Merge: 7798139 2e6fb9d
Author: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Date: Fri Nov 27 09:39:14 2026 +0100
New upstream version 0.0~git20260819.2e6fb9d
commit 2e6fb9d8ee0cdf9e431fbcabe8af3115de000a13
Author: Alex Crichton <alex@alexcrichton.com>
Date: Wed Aug 19 12:56:07 2026 -0500
Support per-task TLS in wasip3 (#872)
This commit is another update to how TLS is handled on the WASIp3 target
in wasi-libc. The problem being addressed here is that bindings
generators (aka `wit-bindgen`) currently use context slot 0 as
task-local storage but this is being co-opted for the stack pointer (and
slot 1 is the TLS base) on WASIp3 targets. This means that bindings
generators don't actually have anywhere to put task-local information
and the previous scheme of implicit threads always using the main thread
TLS meant that there was no way to distinguish anything.
To resolve this the `__wasm_task_hook`, which already exists, now
manages TLS-per-task. This is implemented to work with the full matrix
of {single,multi-module} x {coop-threads,no-coop-threads} through some
refactoring and such. Effectively TLS is dynamically allocated at task
startup and then deallocated when a task completes. Some hooks, like
resource destructors, `_initialize`, post-return, etc, all run with the
"main thread" TLS as before. Tasks can now, on WASIp3 targets, use
normal TLS storage to store task-local data.
> ~~**Note**: this is built on a number of other PRs which are otherwise
blocked on an updated wasm-tools being published, so only the last
commit here is exclusively part of this PR.~~
commit 8fd9d4c2add04448cf2313cd5a20349b084ed96f
Author: Alex Crichton <alex@alexcrichton.com>
Date: Wed Aug 19 12:35:58 2026 -0500
Refactor stack management on wasip3 (#870)
This commit is a refactor of how wasip3 works specifically with respect
to management of the stack and intrinsics used. The end result of this
work is that a number of bugs, present in wasi-libc today, are all
fixed:
* Sync-reentrant calls, allowed in the component model, previously used
the same stack and stomped over each other.
* Resource destructors, executed with fresh task state, did not
correctly setup a stack to execute on.
The fix for the first issue here is particularly gnarly because it means
that stacks are required to be dynamically allocated in some situations.
This in turn means that those same stacks need to be deallocated, and
prior to this commit there was no great place to doing that. The fix for
the second issue is a bit broader than wasi-libc as well as it couldn't
be solved exclusively here.
To resolve these problems this commit updates the `wasm-tools` version
required, notably including recent PRs to adjust how linking works to
transform `__wasm_init_task` and `__wasm_init_async_task` into a
more-generic `__wasm_task_hook` function. This hook function is invoked
in more locations, such as resource destructors, and additionally
subsumes previous custom logic with `cabi_realloc`. Effectively
`__wasm_task_hook` is now the sole location concerned with configuring a
stack and TLS for the task-to-run. This handles all situations such as
sync/async tasks, `_initialize`, `cabi_realloc`, resource destructors,
and post-return. This was implemented in
bytecodealliance/wasm-tools#2603 and bytecodealliance/wasm-tools#2605.
To get existing tests all passing after updating `wasm-tools` many of
the changes here were needed no matter what. To fully exercise the new
functionality, however, I've also started adding a composition-based
test suite which creates two components, composes them together, and
runs that as a test. This creates the ability to test situations such as
resource destructors and reentrant behavior purely within this
repository. My hope is that as we discover bugs/issues elsewhere it'll
be possible to add a small reduced test case to this repo as a
composition. For now the composition tests are pretty simple and only
cover the cases that failed before this PR and now fail after this PR.
commit d8d7c11a1cdf0326ae3b5158e2d9ce8b45d4b455
Author: Alex Crichton <alex@alexcrichton.com>
Date: Wed Aug 19 09:14:06 2026 -0500
Fix a use-after-free in coop threads futex (#871)
This commit fixes an issue where multiple threads waking up on the same
address would all try to free the address and internally would cause
malloc corruption. The fix here is to refcount lists as they reside in
the futex hash map.
commit 355422cd5effd01fde5dc069ae4c34828c1e85f1
Author: Sebastien Tardif <SebTardif@ncf.ca>
Date: Thu Aug 13 13:49:17 2026 -0700
Fix wasip3 blocking UDP subtask handle leaks (#868)
## Summary
On wasip3, when a blocking UDP `recv`/`send` waits for a pending
component-model subtask and the wait completes, the handle must be
dropped. The nonblocking paths already do this. The blocking success
paths only cleared the field and leaked the handle.
- **recv:** call `wasip3_recv_end` after a successful wait (same as the
nonblocking path)
- **send:** do not zero `send_subtask` before the shared
`wasip3_subtask_drop` block so that drop actually runs
- **test:** dual-process blocking UDP roundtrips (64 cycles); server
blocks in `recvfrom` before each client send so a pending receive
subtask is common
Timeout paths still leave the subtask in place for a later retry.
## Origin
Introduced in #775 (2026-04-03) when nonblocking UDP I/O was added.
## Related
- Nonblocking completion already drops via `wasip3_recv_end` / shared
send drop
- #775 wasip3 nonblocking UDP
- #763 wasip3 UDP
commit 85d6701392d9e93643cefd689e5db1007d7dd67a
Author: Sebastien Tardif <SebTardif@ncf.ca>
Date: Wed Aug 12 13:33:40 2026 -0700
Fix wasip1 accept(NULL) crash and emulated mmap leak on pread failure (#866)
## Summary
Two small correctness fixes in wasip1 `accept`/`accept4` and emulated
`mmap`.
## Problem
1. **wasip1 accept:** After a successful `__wasi_sock_accept`, both
`accept` and `accept4` always wrote through `addr` / `*addrlen`. POSIX
allows both to be NULL when the peer address is unused, so `accept(fd,
NULL, NULL)` null-dereferences. wasip2/p3 already allow both-null via
`__wasilibc_sockaddr_validate`.
2. **Emulated mmap:** File-backed `mmap` allocates a header+body block,
then fills it with `pread`. On `pread` error it returned `MAP_FAILED`
without freeing that allocation.
## Change
- `accept-wasip1.c`: only fill the sockaddr when both `addr` and
`addrlen` are non-NULL.
- `mman/mman.c`: on `pread` failure, free the allocation and restore
`errno`.
## Validation
- **Suite tests** (this PR):
- `test/src/sockets-accept-null-addr.c` — `accept`/`accept4` with NULL
peer address (plus a non-null control path). Registered for wasip2/p3
NETWORK and for wasip1 (non-V8) so `accept-wasip1.c` is exercised.
- `test/src/mmap-pread-fail.c` — emulated mmap: O_WRONLY `pread` failure
returns `MAP_FAILED`, survives 256×1MiB fail iterations without OOMing,
then `MAP_ANON` still works. Linked with `-lwasi-emulated-mman`.
- Host red-green for both control-flow classes (null-write crash vs
both-null guard; free-on-fail vs leak growth).
- `clang-format` on touched C sources.
## Origin
- accept NULL write path from #287 (2022-05-02).
- mmap `return MAP_FAILED` without free from
[20c48b57](https://github.com/WebAssembly/wasi-libc/commit/20c48b57)
(2019-05-04).
## Related
- #206 / #207 track other emulated-mmap limitations (writeback,
alignment), not this leak.
- #635 is prior art for small resource-leak fixes in this tree.
---------
Signed-off-by: Sebastien Tardif <sebtardif@ncf.ca>
commit 630cf37bba53dd0498134544e5caf89cba8fa057
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Aug 11 09:20:51 2026 -0500
Convert the open-posix-test-suite repository to a subtree (#864)
This is intended to make it easier to modify the tests, primarily to
avoid them taking 10+ seconds and instead take a much smaller amount of
time. The upstream repository is a fork of the original repository which
hasn't changed in years, so this is expected to largely just be a
one-time import. I've trimmed some of the larger parts of it to avoid
adding too much size to this repository.
commit 79c1a738e1b3df432545666a1a579c49a82b4514
Author: Alex Crichton <alex@alexcrichton.com>
Date: Mon Aug 10 14:11:57 2026 -0500
Support shared-library TLS (#858)
This commit updates handling of TLS as specified in #857 throughout
wasi-libc. Actually getting this all working will additionally require
changes in `wit-component`, and subsequently `wasm-component-ld`. For
more information, and rationale, see #857.
commit 44113af871380a290933332dc4d11a74254a57f7
Author: Alex Crichton <alex@alexcrichton.com>
Date: Mon Aug 10 12:48:13 2026 -0500
Add tests for external non-main entrypoints (#863)
This adds a bit of test building logic to be able to write tests for
non-main entrypoints. This came up as part of rust-lang/rust#160828
where a new test passed when invoked via `main` but failed when invoked
via a non-`main` entrypoint. The actual test in question is already
fixed in `main` for this library so the change here is effectively just
adding a regression test plus some new test infrastructure.
commit 4a066faaf71dd65b2cfccbfb64b97b6ee90c78fb
Author: Calvin Prewitt <calvin@setout.dev>
Date: Mon Aug 10 09:32:40 2026 -0500
wasip2: check the `descriptor.read` result before consuming it (#862)
Fixes #861.
The wasip2 `pread` glue read the result tuple's length and pointer,
copied from the pointer, and freed it before checking the call's ok
flag. On an error result the binding does not write the tuple, so all of
that operated on uninitialized stack memory — a read through a garbage
pointer and a `free` of a garbage pointer, before the error was ever
translated to an errno.
Two changes, both in the `__wasip2__` branch of `pread.c`:
- Move the error check ahead of any use of the result, matching what
`readlinkat` and `pwrite` already do.
- Clamp the returned length to the requested size before the `memcpy`,
so a host that returns more bytes than asked for cannot overflow the
caller's buffer.
No behavior change on the success path for conforming hosts.
---------
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
commit 8d8348ec24253d0638a693b8af82445c13d92d32
Author: Alex Crichton <alex@alexcrichton.com>
Date: Fri Aug 7 12:09:57 2026 -0500
Update WASIp2 bindings to 0.2.12, use exit-with-code (#860)
So far wasi-libc has never updated its wasip2 bindings, and I feel it's
about time this is done. This is used to get access to exit-with-code.
Users needing to use the older version of WASIp2 can continue to use
historical versions of wasi-libc/wasi-sdk, much the same as needing to
use an older LLVM version.
commit 6d8745c8cec1aaa82c24f2e3d7a544f7ea9c2089
Author: Alex Crichton <alex@alexcrichton.com>
Date: Thu Jul 30 19:04:02 2026 -0500
Route `__wasm_get_stack_pointer` as an import (#856)
This is a commit to address #805 by routing the
`__wasm_get_stack_pointer` function directly to an imported function.
This is done by defining a symbol which is itself an import. This is
done in `crt-*.o` objects because this needs to be redefined for all
shared libraries as well.
Closes #805
commit f3e872871c6fb77db9727a18ab812a1a8f6e85ce
Author: Alex Crichton <alex@alexcrichton.com>
Date: Mon Jul 27 09:18:03 2026 -0500
Configure a new stack in `cabi_realloc` (#854)
This commit is an update to the `cabi_realloc` export configured by
wasi-libc, specifically for wasip3 targets. The change here is to change
the entrypoint from a C function to a small assembly wrapper which
configures the stack pointer and TLS base before calling into C. This is
to account for the spec change in WebAssembly/component-model#680 where
`realloc` hooks are now going to be invoked with context slots set to 0.
This means that `cabi_realloc` runs with no stack, and this would
quickly abort in wasi-libc otherwise.
The change here is to, when the ABI is using `context` slots for the
stack pointer, have an assembly wrapper that configures a known-good
stack and TLS block for `cabi_realloc` to use. Once configured the
normal C-based `cabi_realloc` routine runs. This is tested against
bytecodealliance/wasmtime#13949 to ensure it works on the p3 target
with/without coop threading and before/after that Wasmtime change.
commit 0d5332aceea8e72698b6abc270550e666ba97aea
Author: Alex Crichton <alex@alexcrichton.com>
Date: Thu Jul 23 17:05:38 2026 -0500
Test wasip3, without coop threads, with LLVM 23 in CI (#853)
* Fix an issue where the wrong compiler-rt was used. This was keyed on
coop threads when it should be keyed on the ABI of the wasip3 target.
This additionally required moving ABI detection up in CMake.
* Tweak the check-symbols logic because now wasip3 has pretty different
symbols depending on LLVM 22/23, and it needs to pass on both.
* Adjust `__init_tls.c`'s fetching of the stack pointer to use the ABI
in question rather than coop threads to determine how to get the stack
pointer.
* Don't build shared tests for wasip3 with the libcall ABI as that's
what's broken, not just coop threads.
commit 297b285d353b8808ce1a58d594c9ad219313a396
Author: Alex Crichton <alex@alexcrichton.com>
Date: Thu Jul 23 12:02:30 2026 -0500
Fix coop-threads futex, consolidate primitives (#851)
This commit is a consolidation of threading primitives across all
targets that wasi-libc supports. All implementations from the
single-threads and coop-threads builds are deleted and the wasi-threads
ones, the ones that were originally in Musl, are moved to `common` and
compiled on all platforms. This is intended to bring battle-tested (in
theory at least) versions to be used by all programs. The intention is
that semantically everything behaves the same, but hopefully there's a
bit more POSIX-compat around the corner.
This exposed a bug in the coop-threads futex implementation where
waiting threads erroneously assumed their futex entry's address did not
change over time. This bug meant that cleanup after the wait operation
would corrupt the heap and/or not work correctly. The fix here is to
refactor the hash map usage slightly and store the queue of nodes
separately on the heap so it's resistant to hash map resizes. This
failure was exposed by a preexisting test which failed once files were
consolidated and passes after the fix.
This additionally disables one test from the open-posix-testsuite which
exhibits UB of reentrantly acquiring a write lock on a rwlock, expecting
it to return `EDEADLK`, which isn't guaranteed.
Closes #811
commit 375b2daaa0d91d83eb38e634ecaf3827c1515dbe
Author: Alex Crichton <alex@alexcrichton.com>
Date: Thu Jul 23 11:01:24 2026 -0500
Implement UDP send/receive timeouts (#852)
Needed for the Rust standard library's test suite and an otherwise open
gap in the implementation in wasi-libc.
commit 28a93d5ef5ef9cfb3b36bb28fb645b8de359a8f2
Author: Alex Crichton <alex@alexcrichton.com>
Date: Wed Jul 22 11:31:22 2026 -0500
Test Python with coop threads in CI (#850)
This commit is the culmination of many previous PRs and changes to make
Python able to run all of its tests in wasi-libc's CI with the
`wasm32-wasip3` target with coop threads enabled. This notably means
that Python is able to run all of its tests with threads, socket, you
name it. This is a much larger portion of tests covered than the
`wasm32-wasip2` target, for example, because threads are enabled.
This naturally needed to adjust the Python source itself (the patch in
this repository). A number of tests still need manual skips for WASI or
more filtered conditions for when to run. For example wasi-libc still
doesn't provide anything related to signals and some tests in Python
assume the presence of signals. The goal here though is to, ideally,
ignore pretty few tests in the grand scheme of things.
I'll also note that there are some tests in Python which require
preemptive scheduling. They'll hang or fail with coop threads, and
they've been annotated as such.
And, finally, there's a few edge-case tests that require WASI
workarounds for various I/O behavior and WASI behavior. For example
`close` can block, unlike other platforms. Additionally the precise
behavior of syscalls may sometimes require more turns of the event loop,
things like that.
I don't think that the Python patch here is upstreamable as-is, but my
hope is that this is at least a basis by which something could
eventually be upstreamed.
> ~~**Note**: this is temporarily stacked on #849~~
commit ef0bf96145b33ab8c8152f1f594e5a8a470aa7a3
Author: Alex Crichton <alex@alexcrichton.com>
Date: Wed Jul 22 11:18:55 2026 -0500
Update to wasi-sdk-34.0-rc.2 (#849)
The `--export-table` argument is no longer needed and the type of
`__init_tls_base` needed adjusting.
commit ef47972ca52e1aac8509546eac91c9770584555f
Author: Alex Crichton <alex@alexcrichton.com>
Date: Wed Jul 22 09:50:19 2026 -0500
Add futex relative sleeps and wakeup counts (#846)
This commit is a refactor of some futex-related functionality in
addition to adding some new functionality. Specifically:
* `__wasilibc_futex_wait` now specifies a
`__WASILIBC_FUTEX_TIMESPEC_ABSOLUTE` value for the `flags` argument
which indicates whether the timespec specified is absolute or relative.
* The `__wasilibc_futex_wake` API now returns the number of threads
woken on success.qj
* The `__wait.c` functions shared amongst targets is now in the `common`
directory and is implemented in terms of `__wasilibc_futex_*`.
Per-implementation functions previously implemented in terms of these
functions are now migrated to internal implementations. This removed the
unused `int op` in the wasi-threads implementation, for example.
This is originally motivated by looking at Rust and seeking how the
`wake` functionality wants to know if something was woken up, and
additionally how the timeout there is specified as a relative duration.
Additionally the wasi-threads backend only supports relative timeouts,
and the coop-threads backend supports either relative or absolute, so it
wasn't too hard to integrate.
commit 323e68664d0576d982afdb3c2bc8ca3372da1045
Author: Alex Crichton <alex@alexcrichton.com>
Date: Wed Jul 22 09:13:19 2026 -0500
Remove pthread_{kill,sigmask} stubs (#848)
These are already not present in the header file (gated out). Take the
same route as all other signal-related functions by removing them
entirely instead of providing stubs.
commit af323bda7f3ea816ebefd8e307619920432af89c
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 21 18:21:40 2026 -0500
Enable more easily using wasi-sdk versions in CI (#847)
Abstract the installation github action a bit to make it easier to
configure and use it when testing Python. This additionally fixes some
issues when testing Python to use the configured compiler rather than
what happened to be at `WASI_SDK_PATH`.
commit 7862a8790acb1a6a1f8c6ad889cc07508c9b7d85
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 21 16:38:51 2026 -0500
Block on pending writes in `close` (#845)
This commit updates the `close` function to block on pending socket
writes if they are present. This was already done for UDP `send`s but I
forgot to do this for TCP/files/etc. This is effectively the decision
reached in WebAssembly/component-model#617.
This is a bit of a curious case as well because the blocking behavior in
`close` is only needed when writes are buffered by wasi-libc, and writes
are only buffered when a stream is deduced as not respecting 0-length
operations for readiness. The test case here is written with TCP, and
TCP is the poster-child for "should respect 0-length operation", so the
entire premise of this commit may be a bit suspect.
The underlying cause, however, is how Tokio and certain interleavings of
`poll` work together. Tokio, Wasmtime's runtime for TCP, will report a
TCP stream are ready for writes with no syscalls performed until some
operation actually hits `EWOULDBLOCK`. This means that performing a
zero-length operation is a noop until something else actually blocks.
Normally this is fine, but it means that wasi-libc can deduce that
Wasmtime's TCP streams are misbehaving via:
* A socket is filled such that one more call to `write` will block, but
otherwise hasn't blocked yet.
* A call to `poll` is made which does a zero-length write. Tokio's never
seen `EWOULDBLOCK` so it says that the stream is immediately ready.
* The next call to `write` thinks that the previous zero-length write
should force readiness, but now Tokio discoveres for the first time that
the socket isn't ready, blocking the write. This confuses wasi-libc into
thinking that writes must be buffered now.
This can probably be fixed with enhanced logic in wasi-libc, but it's
also orthogonal to the actual fix here. The actual fix is needed no
matter what, blocking on reported-successful writes. A future
optimization in wasi-libc might mean that it doesn't so aggressively
start buffering writes, but that's left for later. For now the test
included here exercises this path, and while it might stop in the future
that's hopefully not a huge issue.
commit 6bfca9c7d5183339c982cbbff4cf1fc554350e0e
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 21 13:00:40 2026 -0500
Don't fail all of `poll` on one bad fd (#844)
This commit implements the documented behavior of `poll` where if one
file descriptor is bad it's returned as `POLLNVAL` rather than failing
the entire call to `poll`. Note though that this is undone in `select`
where one bad fd does fail the entire call.
commit eb960fea43833f2b99ab4ccf4845ae3aaa1ef918
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 21 12:57:45 2026 -0500
Use `ESPIPE` for lseek failures (#843)
Matches Linux's behavior in terms of error codes, needed to unblock some
Python tests.
commit fb2edcef33395cd18f5921041f9c40d6127adc68
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 21 12:28:36 2026 -0500
Handle the `IPV6_V6ONLY` socket option (#839)
This is always set for ipv6 sockets so always return enabled and reject
requests to disable it.
commit da3f2e5bd732844165eb5daecf42fa0cfe8aa650
Author: Sy Brand <sy.brand@fastly.com>
Date: Tue Jul 21 18:26:54 2026 +0100
Public-facing futex API (#834)
Adds `__wasilibc_futex_{wait,wake}` functions that can be used by
external code to use futexes across cooperative or wasi-threads builds.
The functions trap in single-threaded builds.
We could have separate `__wasilibc_futex_wait` and
`__wasilibc_futex_timed_wait` functions if we want a simpler API for
clients that don't need the timed behaviour. I don't have particularly
strong feelings either way.
commit efd03d20aba093de6798f6b1438493cc39dc04f1
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 21 11:55:19 2026 -0500
Implement `pipe` and `pipe2` on WASIp3 (#826)
This is expected to assist with porting applications to WASI as these
are quite common syscalls. With WASIp3 these are also now able to be
natively implemented. This commit fills out a simple-ish implementation
which isn't focused on speed but is intended to at least be correct.
One important note is that pipes aren't backed directly by `stream<u8>`
as might otherwise be expected. This is to be able to implement
buffering behavior which the component model does not support.
Specifically applications frequently expect `write` on a pipe that's
known to be empty to generally not block, and this implementation
preserves that assumption.
Internally, however, `stream` is still used. This enables `pipe` to get
connected to `poll`, for example.
Closes https://github.com/WebAssembly/wasi-libc/pull/726
> **Note**: this is built on
https://github.com/WebAssembly/wasi-libc/pull/825
commit 8328dc27725c8d6fdf9cd20867390ca7e9bde951
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 21 11:28:41 2026 -0500
Don't abort on invalid-state errors (#838)
This error code represents not only invalid states in API calls but also
normal errors like `ENOTCONN`, so translate it as such.
commit 3a998510f1a5b79800961f7514e9d2e682dc6b8b
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 21 11:13:22 2026 -0500
Handle another WASIp3 error in networking (#837)
The new `connection-broken` error wasn't handled yet.
commit 2c5d9a57f6bd22bda363f131948743b4c5a94f55
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 21 11:13:07 2026 -0500
Define file locking constants, return `ENOSTUP` (#841)
We've generally not done too well historically avoiding defining things
entirely, so this defines file locking constants for `fcntl` and returns
`ENOTSUP` when they're passed in. It'll be up to applications to
gracefully handle this lack of functionality in WASI.
commit f60e7e7c3c59c12c9bfd738689c89762bd20b5be
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 21 11:12:41 2026 -0500
Fill out some more of `getaddrinfo` (#840)
Used by Python's test suite and gets a number of Python tests passing.
commit 7f978f2b773fb7aae72ca05926739912646b7527
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 21 09:46:10 2026 -0500
Add internal locks for I/O primitives (#825)
This commit goes through the I/O subsystems of wasi-libc for WASIp3
(TCP, UDP, files, and stdio) and adds necessary internal locks and
synchronization. None of this has been previously required because
threading was not possible so it wasn't possible to have parallel
operations issued, but with WASIp3 coop threads on the horizon this will
soon be possible. The goal of this commit is to ensure that I/O objects
all behave "reasonably" for operations issued in parallel.
The general strategy here is to add a libc-internal lock-per-object. All
operations on the object start by acquiring the lock and then end by
releasing the lock. The main question to deal with is what to do with
blocking operations where a thread blocked in `read` shouldn't block a
sibling thread doing a `write`, for example. To handle this each
blocking operation drops the object's `lock` before issuing the blocking
operation. State is left behind to indicate that a blocking operation is
in-progress, however. Another part to handle here is that calls to
`poll` leave objects in "blocking I/O in progress" state while the call
to `poll` is active as well.
The general problems that need to be protected against are:
1. Component model primitives can only reside in one waitable-set at a
time. This means that if a thread is blocked on a waitable-set with
stream and another thread puts that stream into a different
waitable-set then the first thread won't operate correctly any more.
2. Component model streams only support at most one active operation on
a stream at a time. Once issued another thread can't start a new
operation.
3. Blocking operations in the component model cannot be cancelled. For
example a thread blocked in `read` can't get cancelled by a thread
calling `close`.
For wasi-libc this effectively gives rise to the constraint that once a
thread is blocked in an I/O operation the object in question can't
handle any other requests for I/O. For example one thread blocked in
`read` means that another thread doing a nonblocking `read` basically
can't be supported. This also happens for other issues like another
thread doing `poll`, for example. For now these sorts of concurrent I/O
requests return `EOPNOTSUPP` to at least indicate that wasi-libc doesn't
support what's happening. I'm not sure if this is going to be a viable
strategy long-term, but my hope is that this covers the vast majority of
real-world use cases of concurrent operations on file descriptors.
Note that parallel reads/writes on the same file descriptors are
intentionally supported. This is a known use case in the wild for many
libraries so this is explicitly allowed and handled within wasi-libc,
but mostly just because it falls out that these operations are happening
on separate streams.
> ~~**Note**: this is temporarily built on
https://github.com/WebAssembly/wasi-libc/pull/822~~
commit f5372cfba0583ec384ba8694f98a4bdd69433d67
Author: Alex Crichton <alex@alexcrichton.com>
Date: Mon Jul 20 09:27:08 2026 -0500
Fix recursive thread initialization on the main thread (#836)
This commit fixes issues running upstream Python tests with threads that
was introduced in #820 as an accidental regression. Specifically the
condition used for lazy initialization, the TID is 0, is also true
during thread teardown when the TID is cleared. The condition for "lazy
init needed" is switched to handle something more robust, the
self-pointer in the TLS block.
commit 22a4288cbdeea7c0d6267ab38ce8194968e1be56
Author: Alex Crichton <alex@alexcrichton.com>
Date: Fri Jul 17 17:26:22 2026 -0500
Add `ppoll` symbol to wasi-libc (#835)
In addition to being nice for portability (see #814) this additionally
provides a means of polling with a more precise timeout than the
milliseconds that `poll` defines. Like `pselect` the sigmask argument is
ignored here since WASI has no signals.
Most of this change is just moving the implementation of `poll`, and
then some light edits are done to handle the `timeout` parameter
differently.
Close #814
commit d30f0aef98b2791d407c7a0450854f1231ba2104
Author: Alex Crichton <alex@alexcrichton.com>
Date: Fri Jul 17 12:56:02 2026 -0500
Implement `dup`-family functions (#832)
This commit builds on the work of
https://github.com/WebAssembly/wasi-libc/pull/822 to implement
`dup`-style
functions. Notably `dup`, `dup2`, `dup3`, and `F_DUPFD{,_CLOEXEC}` are
now implemented for wasip2/wasip3 targets. The wasip1 target is left
unmodified here. The goal of this commit is to unblock more tests being
run in Python upstream where a number rely on these functions. With the
reference counting in https://github.com/WebAssembly/wasi-libc/pull/822
the functions are relatively easy to
implement, although this required refactoring the descriptor table
itself to support these operations.
Previously the descriptor table allocated in a LIFO manner but this has
been replaced with a POSIX-compliant lowest-value-returned instead.
Closes https://github.com/WebAssembly/wasi-libc/issues/802
> ~~**Note**: this is built on #822~~
commit f4cdae7468e5065bba9a90310e428d97bfcde03a
Author: Alex Crichton <alex@alexcrichton.com>
Date: Fri Jul 17 12:54:46 2026 -0500
Adjust sendto/recvfrom on TCP sockets (#830)
Ignore the address arguments instead of returning an error when they're
specified. This helps get some tests passing in Python and also matches
Linux behavior.
commit c86c8d0f436e55f964d95b1147e5e5278584f08d
Author: Alex Crichton <alex@alexcrichton.com>
Date: Fri Jul 17 12:20:29 2026 -0500
Tighten POSIX semantics for listen (#831)
Handle the case when the `backlog` argument is less than 1 (0 or
negative) by selecting an implementation-defined minimum, in this case
0. WASI rejects 0 but POSIX doesn't, and this helps get an upstream
Python test passing.
commit e247a70cf08ad33c582ecc24c304c6ccfc381a0d
Author: Alex Crichton <alex@alexcrichton.com>
Date: Fri Jul 17 12:02:45 2026 -0500
Support thread names on coop threads (#828)
Relatively easy to support at least a small name and this'll help
unblock some tests in the upstream python test suite.
commit 13d811b4e8340dc21b4d91d4c7547ac7cb7f0046
Author: Alex Crichton <alex@alexcrichton.com>
Date: Fri Jul 17 12:02:16 2026 -0500
Combine pollfds in `select` (#829)
This commit updates the behavior of `select` delegating to `poll` to
combine fds in different select sets into a single `pollfd` to pass to
`poll`. This helps handle the restrictions added in #825 where the same
fd can't be in the same set twice.
commit d38715215ad467f0ac169c9f39f0f46cd72590bf
Author: Alex Crichton <alex@alexcrichton.com>
Date: Fri Jul 17 09:42:26 2026 -0500
Implement reference counting of I/O descriptions (#822)
This commit changes the `descriptor_table.h` internals, headers, etc, to
reference-count the entries that are inserted. The goal of this work is
to lay the foundation for #807. At this time there's no synchronization
around the descriptor table for WASIp2/WASIp3 because there need not be,
but with coop threads this will no longer be optional. For example it'll
be possible for a thread to call `close` while another thread is blocked
in `read` on that, and the result shouldn't be UB such as a trap.
At the very least code needs to execute at the start of I/O operations
to flag that certain descriptors are in-use, and code needs to run at
the end of I/O operations to indicate that the descriptor is no longer
in-use. Today that's not possible because descriptors are borrowed raw
from the table with no modifications. Reference-counting descriptors is
intended to match the underlying implementation on Unix-style operating
systems which is intended to enable more natural implementations of
eventual semantics for concurrent I/O operations. After this commit
concurrent I/O ops are still not safe (e.g. may trap, cause UB, etc),
and work will be done in subsequent commits to fix this for I/O
subsystems.
This commit starts out by adding a reference counter to the start of all
I/O descriptions that are allocated. This is managed by
`descriptor_table_*` functions with incs/decs and a deallocation when
the count reaches 0. The table itself holds a strong reference count to
all items, and then whenever something is looked up within the table it
additionally gets a strong reference count returned. This is radically
different from today's APIs where the `descriptor_table_entry_t*` points
directly within the global table. The problem, then, is that all
previous callers of `descriptor_table_get_ref` need to get updated to
`descriptor_table_get` plus a deallocation routine.
Personally I do not have faith in myself manually placing deallocation
routines. What I've opted to do here is to raise the Clang baseline for
WASIp2/WASIp3 targets to Clang 22. With Clang 22 the `-fdefer-ts` flag
is now available and the `defer` keyword can be used, massively
simplifying the decrement of the reference count path (and resource
cleanup in general). I've not touched WASIp1 here mostly because I just
don't want to ruffle feathers. If someone else wants to use `defer` for
WASIp1 I think that's fine, but I'm not going to be the one to introduce
it.
The end result of this commit is that all I/O descriptions have a
reference count and nothing borrows directly from the global I/O table
itself. All I/O operations have a local strongly-owned copy of the
description that they're working on. This now simplifies the problem of
concurrent I/O to "figure it out within this object" as opposed to "is
your object even valid?". I plan to do further work after this PR to
audit various subsystems for modifications to I/O descriptions, add
locks where appropriate, etc. Notably the descriptor table itself won't
need locks in coop threading mode, just the I/O objects themselves will
need internal synchronization/assertions/etc.
One note to call out is that testing this behavior is kind of hard. The
consequence of a leak (forgotten dec ref) is that nothing happens.
Everything generally proceeds as expected, so there's no easy way to
write a test that everything's actually cleaned up. I've opted to add a
debug-mode-only assertion to libc itself on program exit (hooked via
`crt1-command.c`) that closes all descriptors and then asserts that the
only live allocations are the stdio descriptors. This is intended to at
least work with wasi-libc's test suite for detecting leaks (and caught
one during development).
A final note is that this additionally opens up the door to implement
`dup` on WASIp2/WASIp3 targets. I think this'll be a useful tidbit for
POSIX compat (see #802) and will have a mostly trivial implementation
after this PR lands.
commit 2bb8a905534fa460faebcd19bed363867a765d68
Author: Sy Brand <sy.brand@fastly.com>
Date: Fri Jul 17 15:40:11 2026 +0100
Futex-style API for locking primitives in cooperative threading mode (#827)
Adds a futex-style API for cooperative threading mode that serves to
unify the ABIs of locking primitives across targets.
The meat of the change is to provide a similar interface to the one used
in wasi-threads mode, but that is implemented under the hood by a hash
map from futex addresses to cooperative waitlists.
I opted to use an existing MIT-licensed [hashmap
implementation](https://github.com/tidwall/hashmap.c). We could do more
aggressive optimisations, but this should be serviceable for now.
Partially addresses https://github.com/WebAssembly/wasi-libc/issues/823:
we should make a more public-facing API that is accessible on all
targets.
commit 7226b5352bb851233b639db75780d3973aaa9077
Author: Alex Crichton <alex@alexcrichton.com>
Date: Fri Jul 17 09:26:07 2026 -0500
Set new thread structures to 0 by default (#833)
This commit fixes a use of uninitialized memory for coop threads when a
new thread starts. Specifically the `struct pthread` structure was never
fully initialized and some fields were left to their
previous-heap-allocated state. This is intended to fix the [CI
failure][log] found on a sibling PR.
[log]:
https://github.com/WebAssembly/wasi-libc/actions/runs/29524494592/job/87709369693?pr=826
commit 7d831af67cc41327a826b446e90eff8fbe4fb601
Author: Alex Crichton <alex@alexcrichton.com>
Date: Wed Jul 15 14:38:06 2026 -0500
Adjust how TLS initialization works (#820)
In reviewing various issues and TLS initialization I was personally left
pretty confused. There were more hooks into TLS than I had anticipated
and I found them to interact in confusing ways. Notably `__copy_tls`
initializes another thread's TLS pointer but uses the `__wasm_init_tls`
intrinsic which sets the current thread's TLS pointer as well. This
means that there was previously a dance that was done to save/restore
this as necessary.
I additionally noticed that TLS initialization for WASIp3 is expected to
be a bit more expensive than other platforms due to an intrinsic
necessary to learn the current TID. This is something that I think would
be worthwhile to take off the hot path.
Finally, I felt that the assembly as part of task initialization was
doing a bit too much relative to what could be done in C.
Adding all these together, the changes here are:
* For wasip3 coop threads, sync tasks use the "main thread" TLS setup in
the `start` function. They no longer allocate their own block of TLS
storage.
* For wasip3 coop threads, async tasks now delegate to C to perform
stack allocation. TLS is then stored at the top of the stack, and the
stack top is returned to assembly to get configured.
* The `__copy_tls` function is no longer used on wasip3 targets with
coop threads. Task initialization after the changes above no longer used
it, and spawned threads now initialize their TLS when they start.
* The `__init_tp` function is now deferred as an internal detail of
`__pthread_self`. This is effectively lazy initialization of
`__pthread_self()`. The CRT startup objects thus no longer need this
symbol for example.
* When spawning a thread, assembly only initializes the stack pointer
and lets C initialize TLS.
* A workaround to consider `__wasi_coop_thread_start` used is removed
since I believe it's not necessary as the symbol is referred to by
function pointer to pass to an imported function.
Throughout this I've attempted to improve comments here and there. A
workaround for #819 is needed temporarily, too. Much of #810 is
addressed, but the stack for async tasks is still leaked which'll need
fixing.
commit bc5d6f2e54e9b7ce4c9682a05f19075906842ac7
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 14 16:08:41 2026 -0500
Remove `close_streams` vtable call (#824)
This was only present for `unlink`, `remove`, and `unlinkat`, none of
which can operate on files so this was pretty much always a noop. I
think this was just carried over without thinking too hard, but this
shouldn't be necessary. This was the only usage of the `close_streams`
callback so there's no need to preserve it.
commit fb6557bd3f943ea92c5826a6e5e090ce859bc729
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 14 11:17:12 2026 -0500
Implement timed waits for synchronization primitives (#821)
This commit goes through coop threads for wasip3 and adds support for
timed waits to all the various primitives. Everything previously
returned some form of error when a timeout was specified, and now the
implementations should all be filled in. Notably the main entrypoint
function, `__waitlist_wait_on`, now has a timeout parameter which
internally is handled as necessary.
The implementation of waiting with a timeout requires creating a
waitable-set, a unit future, and a subtask waiting for the timeout
specified. With these blended together it's possible to wait on either
of the events happening and then process the result as it comes in.
Closes #806
---------
Co-authored-by: Sy Brand <tartanllama@gmail.com>
commit 7c1c53d8837d492f767f3fa11684594d86021cbd
Author: Alex Crichton <alex@alexcrichton.com>
Date: Wed Jul 8 16:15:32 2026 -0500
Add a smoke test for static TLS (#818)
I was editing some stuff around this and my edits were wrong yet tests
passed. Add a test to ensure this doesn't regress.
commit edb48dc5b7d336e28c017adc3106bdb8c62dd436
Author: Alex Crichton <alex@alexcrichton.com>
Date: Wed Jul 8 14:52:22 2026 -0500
Update wit-bindgen to 0.59.0 (#816)
Keeps this up-to-date and additionally brings in some updated naming for
the wasip3 threading intrinsics.
commit ac72584321e64188945f4f1043e3aa0056cb6854
Author: Alex Crichton <alex@alexcrichton.com>
Date: Wed Jul 8 11:32:30 2026 -0500
Enable shared library testing on wasip3 again (#817)
Scopes #813 to just coop threads where some more work needs to be done.
commit 99faad782d1b4a7308ea470d4f57490c1952976f
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 7 17:03:43 2026 -0500
Add testing for coop threads in CI (#812)
This requires using LLVM 23+ which needed minor updates in CI. This
additionally requires a compiler-rt compatible with LLVM 23's ABI
changes for wasip3, which `wasi-sdk-34-rc.1` provides. This then
additionally updates a few minor things for tests such as compiling the
open-posix-test-suite with `-Wno-unused-parameter` and refactoring the
configuration slightly to deduplicate with other tests. Finally, new
files for symbol expectations are added for coop threads as the set of
symbols differs from when coop threads are disabled.
Closes #804
commit fe424ae979d60c6bb36a7c2f752e21a97d7eeca5
Author: Alex Crichton <alex@alexcrichton.com>
Date: Tue Jul 7 17:00:46 2026 -0500
Add testing for coop threads in CI (#812)
This requires using LLVM 23+ which needed minor updates in CI. This
additionally requires a compiler-rt compatible with LLVM 23's ABI
changes for wasip3, which `wasi-sdk-34-rc.1` provides. This then
additionally updates a few minor things for tests such as compiling the
open-posix-test-suite with `-Wno-unused-parameter` and refactoring the
configuration slightly to deduplicate with other tests. Finally, new
files for symbol expectations are added for coop threads as the set of
symbols differs from when coop threads are disabled.
Closes #804
commit e2507dd1d4a4fa2d1163efadede8c75cb2d5ed07
Author: Sy Brand <sy.brand@fastly.com>
Date: Wed Jul 1 03:34:24 2026 +0100
WASIp3 Cooperative Threading (#799)
Currently a draft while the LLVM patches merge and I get all of this
ready for review
---------
Co-authored-by: Alex Crichton <alex@alexcrichton.com>