[codex] Fix libxev poller state leaks#432
Merged
Merged
Conversation
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
runlang | 6e1ef12 | Commit Preview URL Branch Preview URL |
Apr 26 2026, 10:39 AM |
The drain loop in run_xev_close_fd waited only for the original read/write
completions to retire, ignoring the cancel completions we submitted to
libxev. When the cancel CQE was still pending in the io_uring ring, the
function would zero slot.read_cancel = .{}, setting its op to .noop. When
the kernel eventually delivered that CQE, libxev's Completion.invoke()
hit `.noop => unreachable`, crashing with SIGSEGV in
test_poller_close_while_waiting.
Three layered fixes:
1. run_xev_bridge.zig: Drain loop now also waits for read_cancel and
write_cancel completions to reach .dead before resetting their
storage. Reset is now conditional: any completion that is somehow
still .active (drain exhausted) is left alone so its eventual CQE
finds a valid op.
2. libxev io_uring.zig: Mirror the existing kqueue.zig defensive guard —
skip processing CQEs for completions whose flags.state is no longer
.active. This prevents the unreachable crash even if a future caller
resets a completion mid-flight.
3. libxev io_uring.zig: Handle .CANCELED in the .poll case so the
cancelled poll's CQE no longer prints "unexpected errno: 125" to
stderr.
https://claude.ai/code/session_01CSYWLMHrkzjcwCbEwHtCLT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Issues
Fixes #397
Fixes #416
Fixes #424
Fixes #426
Audited #395 and #396: the libxev adapter and default poller wiring are already present on origin/main; this PR fixes the remaining state leak/test gating around that implementation.
Validation
zig buildzig build test(passes; emits the expected negative-test diagnostic formissing())zig build test-runtimezig build test-runtime -Dsanitize=truecould not run on this macOS host becauselibasanandlibubsanare not available in the SDK/Homebrew library paths.