Skip to content

libc: align wasm32 pthread entry stacks#784

Closed
brandonpayton wants to merge 1 commit into
mainfrom
gascity/kd-cfo/kd-c5i.10-sqlite-node-sort-open-db
Closed

libc: align wasm32 pthread entry stacks#784
brandonpayton wants to merge 1 commit into
mainfrom
gascity/kd-cfo/kd-c5i.10-sqlite-node-sort-open-db

Conversation

@brandonpayton

@brandonpayton brandonpayton commented Jun 27, 2026

Copy link
Copy Markdown
Member

What this does

#907 already landed PHP support, ABI 39, and the shared process, VFS, host,
package, and test fixes found during that work. This PR does not replay those
changes.

The unique fix here aligns the stack passed to kernel_clone to the 16-byte
boundary expected by wasm32 code generation. Without that alignment, a fresh
pthread can corrupt stack-based variadic arguments. The regression formats the
same %llx%c shape that exposed the problem in SQLite, but tests the libc
contract directly through a new pthread.

What was removed

The old PR mixed this libc fix with SQLite Node/browser test-runner work. That
harness work now belongs to #783 and is deliberately absent here. No mmap,
package, VFS, or unrelated #769 changes remain; the final diff is exactly one
libc source file and one Sortix regression.

ABI and package impact

The kernel_clone arguments and ABI layout are unchanged, so there is no ABI
version bump. Rebuilding musl changes libc/toolchain artifact bytes. No package
revision changes are included.

Validation run

All validation used scripts/dev-shell.sh on exact head
fc25245984f346a5620998f02f93ad9b85dae80b:

  • wasm32 musl rebuild passed;
  • the focused Sortix pthread regression passed 1/1;
  • the ABI snapshot/version check passed;
  • the full libc suite passed 303 tests, with 20 expected failures and one known
    flaky test that passed on this run;
  • the full POSIX suite passed 174 tests, with 3 expected failures and 2
    supported-boundary skips;
  • three initial /bin/sh setup failures passed after the declared dash/rootfs
    dependency was materialized;
  • kernel, fork-instrument, program, and host build stages completed.

Validation not run

The full browser and Sortix suites were not run locally. Focused host pthread
Vitest did not start because global setup requires a wasm64 sysroot; wasm64 was
not built because this change is in the wasm32 libc implementation. The full
rootfs source-fallback build was stopped after the relevant artifacts existed.
No performance measurement was made and this PR makes no performance claim.

Extracted from the useful pthread portion of #769 and narrowed from the old
composite #784 diff.

@github-actions

github-actions Bot commented Jun 27, 2026

Copy link
Copy Markdown

Phase B-1 matrix build status — pr-784-staging

ABI v39. 71 built, 0 failed, 71 total.

Package Arch Status Sha
icu wasm32 built 1b708b23
libcurl wasm32 built 5d2baeb6
libcxx wasm32 built 10822bd9
libcxx wasm64 built 25ef3300
libiconv wasm32 built c599d681
libpng wasm32 built ba7e28f0
libxml2 wasm32 built d98f801a
libzip wasm32 built 3dd483d4
openssl wasm32 built 424389bb
openssl wasm64 built 912c6480
sqlite wasm32 built 7a1d359e
sqlite wasm64 built d6e76f5f
zlib wasm32 built 8d1bcd09
zlib wasm64 built 72d2453b
bc wasm32 built b698cee4
bzip2 wasm32 built cdb19a37
coreutils wasm32 built c28d9a8a
curl wasm32 built 82d34889
dash wasm32 built 78cb51e3
diffutils wasm32 built bb0fe725
dinit wasm32 built 0dd97701
fbdoom wasm32 built 197275c8
file wasm32 built 81d6e9e3
findutils wasm32 built 2ee580be
gawk wasm32 built 20093498
git wasm32 built d9662860
grep wasm32 built 54ab22a4
gzip wasm32 built 98d8b80e
hello wasm32 built 3894ce0b
kandelo-sdk wasm32 built 1e680135
kernel wasm32 built ddd26fef
less wasm32 built 82b4d006
lsof wasm32 built f615f276
m4 wasm32 built cf2867c0
make wasm32 built c78cf168
mariadb wasm32 built d3638d5d
mariadb wasm64 built 43505255
modeset wasm32 built cb65434e
msmtpd wasm32 built 110af331
nano wasm32 built 7e849192
ncurses wasm32 built 5aac1ff2
netcat wasm32 built e9929ccd
nginx wasm32 built 436389b6
php wasm32 built 2fc5a872
posix-utils-lite wasm32 built cd44f9a1
ruby wasm32 built fafb2e6d
sed wasm32 built d30d7968
spidermonkey wasm32 built 70375ff9
tar wasm32 built 150eb5ed
tcl wasm32 built 214ce39f
unzip wasm32 built 519079b3
userspace wasm32 built 29ed6757
vim wasm32 built 7cab6404
wget wasm32 built 6a064f94
xz wasm32 built 7f2d6ad6
zip wasm32 built 44cbe377
zstd wasm32 built de354193
bash wasm32 built 1b021b0c
mariadb-test wasm32 built ebc24b15
mariadb-vfs wasm32 built ada20fed
mariadb-vfs wasm64 built dbd74217
nethack wasm32 built ffc9e23e
node wasm32 built 60cf998c
spidermonkey-node wasm32 built 7802aac3
vim-browser-bundle wasm32 built e748a6cf
nethack-browser-bundle wasm32 built e6d2b836
rootfs wasm32 built 18d09b37
shell wasm32 built 2f6265da
lamp wasm32 built 221369e3
node-vfs wasm32 built 045bef36
wordpress wasm32 built 40f60c19

Auto-generated; replaced on each push. Raw data in the publish-status workflow artifact.

Align the stack passed to kernel_clone to the 16-byte boundary required by Wasm code generation. This keeps stack-based variadic arguments intact when a new pthread begins.

Add a local Sortix regression that formats the SQLite temporary-file pattern from fresh pthreads. The kernel_clone interface and ABI layout are unchanged.
@brandonpayton brandonpayton force-pushed the gascity/kd-cfo/kd-c5i.10-sqlite-node-sort-open-db branch from cded11d to fc25245 Compare July 13, 2026 20:03
@brandonpayton brandonpayton changed the title Fix pthread stack alignment for SQLite sorter temps libc: align wasm32 pthread entry stacks Jul 13, 2026
@brandonpayton

Copy link
Copy Markdown
Member Author

Closing this focused source PR because its wasm32 pthread stack-alignment fix and direct regression are now carried by #934 at exact green head 260d75d5adc31b327f5591229dbfbb287d395fd6. #934 keeps them as a separate purpose commit and passed the full staging, libc, and Sortix gates. This is not a claim that this branch was merged verbatim.

@brandonpayton brandonpayton deleted the gascity/kd-cfo/kd-c5i.10-sqlite-node-sort-open-db branch July 14, 2026 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant