Skip to content

fix: post-merge P2 findings — EINTR-safe threadSleep, runtime.deinit ownership#126

Open
justrach wants to merge 1 commit intomainfrom
fix/post-merge-codex-p2
Open

fix: post-merge P2 findings — EINTR-safe threadSleep, runtime.deinit ownership#126
justrach wants to merge 1 commit intomainfrom
fix/post-merge-codex-p2

Conversation

@justrach
Copy link
Copy Markdown
Owner

Summary

Follow-up to PR #125. Two P2 issues the Codex reviewer flagged after merge.

  • compat.threadSleep: nanosleep now loops past EINTR, consuming the remaining-time out-param. A single signal could previously collapse a multi-second backoff to near-zero — WAL and background workers rely on the full duration for throttling.
  • runtime.deinit: new owns_threaded flag; deinit() only calls threaded.deinit() when init() actually constructed it. setIo() and ensureForTest() publish externally-owned Io, and tearing down threaded on undefined state would be UB.

Test plan

  • zig build clean (macOS)
  • CI green on macos + ubuntu

🤖 Generated with Claude Code

- compat.threadSleep: nanosleep now loops across EINTR, consuming the
  remaining duration from the kernel's out-param. Previously a single
  signal could collapse a multi-second backoff to near-zero, driving
  unnecessary wakeups in WAL / background workers under signal-heavy
  conditions.
- runtime: track owns_threaded so deinit() only tears down threaded
  when init() actually constructed it. setIo()/ensureForTest() publish
  an externally-owned Io (process.Init's, or global_single_threaded),
  and calling threaded.deinit() on undefined state there would be UB.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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