Skip to content

Update libxev kqueue fix - #50

Merged
lalinsky merged 3 commits into
mainfrom
update-libxev-kqueue-fix
Oct 16, 2025
Merged

lalinsky merged 3 commits into
mainfrom
update-libxev-kqueue-fix

Conversation

@lalinsky

@lalinsky lalinsky commented Oct 16, 2025 •

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • Bug Fixes

    • Improved I/O event handling timing in the run loop.
    • Fixed potential memory safety issue in kqueue backend by ensuring pending deletions are flushed before exit.
  • Chores

    • Updated vendored dependency to version 0.15.2.

71754f7 Fix use-after-free in kqueue no_wait mode
9b6634b update to Zig 0.15.2

git-subtree-dir: vendor/libxev
git-subtree-split: 71754f7223c1ebe068ce931a6cd067d793aa0697
…rocessing

Always call loop.run(.no_wait) first to process cancellations and async
notifications, then check if we need to block with loop.run(.once).

This ensures cancellations and cross-thread notifications are processed
promptly even when there's ready work in the queue.
@coderabbitai

coderabbitai Bot commented Oct 16, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Updates to event loop scheduling in the Zig runtime, a libxev version bump, and modifications to the kqueue backend's exit condition to ensure pending changes are flushed before loop termination.

Changes

Cohort / File(s) Change Summary
Runtime event loop scheduling
src/runtime.zig
Modified Executor.run loop to unconditionally perform non-blocking I/O poll first, then conditionally block if no ready work exists, separating polling logic from blocking decision.
libxev version management
vendor/libxev/flake.nix
Updated Zig package version from 0.15.1 to 0.15.2.
kqueue backend exit condition
vendor/libxev/src/backend/kqueue.zig
Widened loop exit condition to require both zero pending waiters and zero pending changes, ensuring DELETE changes are flushed via kevent_syscall before loop termination to maintain use-after-free safety.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

The changes span three distinct areas with varying complexity: a straightforward version bump, a runtime loop scheduling refactor requiring careful verification of timing implications, and a backend exit condition modification with memory safety considerations.

Poem

🐰 Hops through loops with rhythm true,
Poll, then wait—a fresher view.
Changes flushed before we go,
libxev blooms with 0.15.2's glow! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "Update libxev kqueue fix" is directly related to the actual changes in the pull request. The kqueue.zig file in the libxev vendor directory is indeed being updated with a fix to widen the loop exit condition to prevent use-after-free issues. The title is specific and descriptive, clearly indicating that a kqueue fix in libxev is being updated. While the changeset also includes updates to src/runtime.zig (which adjusts I/O polling behavior) and a version bump in flake.nix, the branch name and the high-effort rating of the kqueue changes suggest the kqueue fix is the primary focus of this PR. The title accurately reflects this primary objective.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch update-libxev-kqueue-fix

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a4bf7a1 and 9524eaa.

⛔ Files ignored due to path filters (1)
  • vendor/libxev/flake.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • src/runtime.zig (1 hunks)
  • vendor/libxev/flake.nix (1 hunks)
  • vendor/libxev/src/backend/kqueue.zig (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-15T08:14:58.285Z
Learnt from: CR
PR: lalinsky/zio#0
File: CLAUDE.md:0-0
Timestamp: 2025-10-15T08:14:58.285Z
Learning: Applies to build.zig.zon : Update the version in build.zig.zon for a release

Applied to files:

  • vendor/libxev/flake.nix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lalinsky
lalinsky merged commit 164599b into main Oct 16, 2025
@lalinsky
lalinsky deleted the update-libxev-kqueue-fix branch October 16, 2025 21:22
@coderabbitai coderabbitai Bot mentioned this pull request Oct 23, 2025
6 tasks done
lalinsky added a commit that referenced this pull request Jan 6, 2026
* Refactor Windows error handling for consistency

- Unify error conversion by creating platform-specific error type alias
- Refactor errnoToFileReadError/WriteError to handle both Windows and Unix errors
- Use centralized error conversion in preadv/pwritev instead of inline switch
- Remove debug print statements from file operations
- Remove unused variable suppression in processCompletion (self is now used)

* Fix socket leak in getExtensions failure path

Close accepted socket when getExtensions fails in processCompletion to
avoid leaking the file descriptor, mirroring the error handling pattern
used for setsockopt failures.
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