Skip to content

Fix libxev poller callback leaks and re-enable poller tests#442

Merged
heartwilltell merged 1 commit into
mainfrom
codex/fetch-runtime-issues-and-implement-fixes
Apr 28, 2026
Merged

Fix libxev poller callback leaks and re-enable poller tests#442
heartwilltell merged 1 commit into
mainfrom
codex/fetch-runtime-issues-and-implement-fixes

Conversation

@heartwilltell

Copy link
Copy Markdown
Contributor

Motivation

Description

  • Add per-fd generation tracking and a CompletionContext userdata in src/runtime/run_xev_bridge.zig so completion callbacks validate the slot generation and ignore stale callbacks from prior fd lifecycles (prevents reuse-related races).
  • Stop reusing raw slot pointers as completion userdata and pass &slot.read_ctx / &slot.write_ctx to file.poll / write completions, with the callbacks checking ctx.generation before acting.
  • Improve run_xev_close_fd by guarding against double-close and draining cancel progress with several bounded non-blocking ticks before clearing slot state to avoid leaving the loop with dangling references.
  • Change run_xev_tick to perform bounded draining of loop.run(.no_wait) until no additional callbacks fire in that tick to avoid dropping additional ready fds (fixes multi-fd callback drop).
  • Re-enable the previously gated runtime poller tests in src/runtime/tests/test_poller.c (test_poller_close_while_waiting, test_poller_pipe_read, test_poller_write_park, test_poller_multiple_fds) so the regressions are covered going forward.

Testing

  • Attempted to run the runtime test suite with zig build test-runtime, but the zig tool was not available in this environment so the runtime tests could not be executed (no automated tests ran here).
  • Verified source changes via repository inspections (git diff) and updated test files to re-enable the gated tests; runtime tests should be executed in CI or a developer environment with zig installed to validate the fixes.

Codex Task

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Apr 27, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
runlang e00efbc Commit Preview URL

Branch Preview URL
Apr 27 2026, 09:58 PM

Addresses #424 and #426 by preventing stale completion reuse across fd lifecycles and draining ready callbacks in run_xev_tick. Re-enables the gated runtime poller tests.
@heartwilltell heartwilltell force-pushed the codex/fetch-runtime-issues-and-implement-fixes branch from e00efbc to 4692255 Compare April 27, 2026 22:36
@heartwilltell heartwilltell merged commit 77489e9 into main Apr 28, 2026
14 checks passed
@heartwilltell heartwilltell deleted the codex/fetch-runtime-issues-and-implement-fixes branch April 28, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant