Skip to content

Deliver SIGEV_THREAD timers to pthread helpers#906

Closed
brandonpayton wants to merge 2 commits into
mainfrom
fix/vim-posix-timer
Closed

Deliver SIGEV_THREAD timers to pthread helpers#906
brandonpayton wants to merge 2 commits into
mainfrom
fix/vim-posix-timer

Conversation

@brandonpayton

Copy link
Copy Markdown
Member

Purpose

Vim's POSIX start_timeout() path uses timer_create(..., SIGEV_THREAD, ...). Musl implements that contract with a helper pthread and lowers the timer notification to Linux-compatible SIGEV_THREAD_ID. Kandelo rejected that exact notification mode with EINVAL, so Vim reported E1286, remained in its timer error path, and left Git waiting indefinitely for the default editor.

This fixes the platform timer contract instead of suppressing Vim timers or adding package-specific behavior.

What changed

  • Keep authoritative per-timer notification state in the kernel, including exact thread targets, SI_TIMER metadata, overrun state, and cleanup.
  • Deliver host timer expirations through a kernel export so both Node and browser hosts use the same queueing and wakeup semantics.
  • Preserve finite sigtimedwait() deadlines across retries and wake the matching blocked thread channel.
  • Build musl with the SDK's Wasm EH/SjLj lowering so its timer helper does not leave unresolved setjmp/longjmp imports.
  • Add an end-to-end pthread SIGEV_THREAD timer fixture and targeted host coverage.
  • Update the POSIX and SDK reference documentation.

ABI

This PR has an intentionally reviewable two-commit shape:

  1. 1382547ac5b6083830bba336d17c5aab7e31348e is the complete functional change.
  2. 0d03f899103408c6c233379072c93b0407c81ced is the isolated ABI 19 bump and generated snapshot/binding update.

The timer delivery export and semantics are ABI-visible, so the standalone PR correctly bumps ABI_VERSION to 19. The ABI batching work in #871 should cherry-pick the functional commit and replace or omit this PR's standalone bump when assigning the consolidated epoch.

No package archives, VFS images, or release indexes are changed here. They must be rebuilt for the final merged ABI epoch.

Validation

Run through scripts/dev-shell.sh on the functional head, followed by ABI consistency checks on the exact PR head:

  • kernel unit tests: 972 passed
  • focused host timer/signal tests: 15 passed
  • targeted POSIX sigtimedwait tests: 5 passed
  • host production build: passed
  • focused POSIX timer pthread fixture: passed on the functional head
  • scripts/check-abi-version.sh: passed on exact head
  • git diff --check: passed
  • independent exact-head review: accepted

The standalone ABI bump has not been followed by a full local ABI 19 artifact rebuild. Full browser, libc conformance, POSIX conformance, and Sortix suites were not run locally; CI is the evidence gate for those claims.

Implement kernel-owned per-timer notification state and exact thread-directed delivery so musl SIGEV_THREAD helpers work on Node and browser hosts. Preserve timer siginfo/overrun metadata, finite wait deadlines, lifecycle cleanup, and the legacy interval export contract. Build musl with the SDK Wasm EH/SjLj model and add an end-to-end regression fixture.
The host/kernel contract now includes kernel-owned POSIX timer expiration delivery and exact SIGEV_THREAD_ID targets. Bump the ABI epoch and regenerate the authoritative snapshot plus C and TypeScript bindings so mixed ABI-18 host/kernel pairs fail loudly.
@brandonpayton

Copy link
Copy Markdown
Member Author

Independent exact-head review completed for 0d03f899103408c6c233379072c93b0407c81ced: ACCEPT.

  • The branch is exactly the accepted functional commit 1382547ac5b6083830bba336d17c5aab7e31348e followed by the isolated ABI commit.
  • The ABI commit is limited to ABI_VERSION 19, the authoritative snapshot, and generated C/TypeScript constants.
  • The combined snapshot includes kernel_posix_timer_fire with its optional host-adapter classification.
  • scripts/check-abi-version.sh and git diff --check pass at exact head; the worktree and index are clean.

No review blocker was found. CI still owns the full ABI 19 artifact rebuild and broad browser/conformance evidence.

@github-actions

Copy link
Copy Markdown

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

ABI v19. 69 built, 0 failed, 69 total.

Package Arch Status Sha
libcurl wasm32 built d91660ac
libcxx wasm32 built 6ab57bf4
libcxx wasm64 built 95a9b1db
libpng wasm32 built 3cd08346
libxml2 wasm32 built 9bd3619f
libxml2 wasm64 built 03616b63
openssl wasm32 built 5ae4fe50
openssl wasm64 built d9d249d6
sqlite wasm32 built 06655b03
sqlite wasm64 built ad7294fe
zlib wasm32 built 347ca36b
zlib wasm64 built 0c033641
bc wasm32 built ef20578a
bzip2 wasm32 built cf7f30e0
coreutils wasm32 built 7f0b7802
curl wasm32 built d0187845
dash wasm32 built f802bddb
diffutils wasm32 built 674b8f44
dinit wasm32 built a8168ccb
fbdoom wasm32 built 0f4818ed
file wasm32 built 0b9fac52
findutils wasm32 built b636d32c
gawk wasm32 built 0a8f6795
git wasm32 built 5ba8c0c6
grep wasm32 built 2aac26f9
gzip wasm32 built 3698a07a
hello wasm32 built 6553ed19
kandelo-sdk wasm32 built 4062f2d6
kernel wasm32 built be880b01
less wasm32 built 7f9297f6
lsof wasm32 built dbdabdbb
m4 wasm32 built 6fd6a44b
make wasm32 built cfb18f6e
mariadb wasm32 built deaffec4
mariadb wasm64 built 4adc1d3b
modeset wasm32 built 24d1188e
msmtpd wasm32 built 275d3474
nano wasm32 built e88a4c8d
ncurses wasm32 built 4c36b411
netcat wasm32 built 319765d3
nginx wasm32 built 76a029d6
php wasm32 built 2d325e8d
posix-utils-lite wasm32 built 818c4bb5
ruby wasm32 built 7c32e926
sed wasm32 built dc5d015b
spidermonkey wasm32 built 72ee84d8
tar wasm32 built 3c8d4efe
tcl wasm32 built 13ec97f7
unzip wasm32 built 1c8bc9c1
userspace wasm32 built 95446055
vim wasm32 built 088793df
wget wasm32 built 099fffa4
xz wasm32 built 3f435f79
zip wasm32 built cd9a1e95
zstd wasm32 built 9bc9f13e
bash wasm32 built 8b4bd77a
mariadb-test wasm32 built b0273594
mariadb-vfs wasm32 built 317f8ee0
mariadb-vfs wasm64 built b6fa7e8a
nethack wasm32 built 10851493
node wasm32 built 9a4036cf
spidermonkey-node wasm32 built 0516a7ee
vim-browser-bundle wasm32 built c3e294a1
nethack-browser-bundle wasm32 built 2b945cc9
rootfs wasm32 built 0036fdc9
shell wasm32 built 5f332d81
lamp wasm32 built ade2ef08
node-vfs wasm32 built d2b85408
wordpress wasm32 built 29a03d35

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

brandonpayton added a commit that referenced this pull request Jul 13, 2026
Keep timer expiration state in the kernel while the shared host runtime schedules deadlines and wakes the exact main or worker thread selected by SIGEV_THREAD_ID. Preserve SI_TIMER metadata, overruns, finite sigtimedwait deadlines, and timer cleanup across exec and deletion.

Reconcile musl's SIGEV_THREAD helper with the fixed four-i32 timer wire on wasm32 and wasm64, and make kernel_posix_timer_fire a required host-adapter export. Regenerate the ABI snapshot and generated constants atomically with the ABI 38 to 39 bump.

Source-PR: #906
@brandonpayton

Copy link
Copy Markdown
Member Author

Merged PR #907 supersedes this work through the strengthened timer-delivery implementation now on main at e15edcef3. This head was not merged verbatim; the merged commit preserves the intended behavior in the ABI39 batch.

@brandonpayton
brandonpayton deleted the fix/vim-posix-timer branch July 13, 2026 16:58
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