Skip to content

fix(fifo): skip runner probing when the control FIFO has no reader - #37

Merged
not-matthias merged 2 commits into
mainfrom
cod-4460-fix-fifo-issues-reported-by-firefox
Nov 26, 2026
Merged

not-matthias merged 2 commits into
mainfrom
cod-4460-fix-fifo-issues-reported-by-firefox

Conversation

@not-matthias

@not-matthias not-matthias commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

TLDR: Leftover /tmp/runner.{ctl,ack}.fifo files with no runner made instrument_hooks_init() block ~4 s before falling back to no instrument; init now detects the missing reader and falls back immediately (POSIX only).

  • Pipe.hasReader: non-blocking O_WRONLY open of the control FIFO, which fails with ENXIO when nobody reads it. RunnerFifo.init returns error.NoRunner in that case. A live runner holds the FIFO open, so it is unaffected.
  • validate_protocol_version now returns AckTimeout instead of continuing into GetIntegrationMode, which would time out too. Swallowing it (1460da1) was only meant to avoid exit(1); Instrument.init already falls back to the no-op instrument. Every runner that knows GetIntegrationMode also knows SetVersion, so continuing never helped.
  • FifoInstrument.init closes the FIFOs when the version check fails, draining late acks before the next probe.
  • dist/core.c regenerated with just release. Most of its diff is symbol renumbering, which also appears when regenerating main unchanged with Zig 0.14.1.

instrument_hooks_init() from a C program linking dist/core.c:

Case Init time
No FIFOs 0.10 ms
Stale FIFOs (mkfifo) 0.08–0.11 ms
Reader holds ctl FIFO, never replies 2.0 s (was ~4 s)

Fixes #36

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Confidence Score: 4/5 · The PR appears safe to merge, with a non-blocking request for timeout-and-cleanup test coverage.RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect instrument startup for applications that use the shared hooks library.

The PR appears safe to merge, with a non-blocking request for timeout-and-cleanup test coverage.

FindingsFix All in Claude CodeFindings

  1. P2 Timeout cleanup lacks test coverage ▶
Fix with agent prompt
### Issue 1
src/instruments/fifo_instrument.zig:16-19
The new stale-FIFO test returns from `RunnerFifo.init` before it reaches this cleanup or the changed timeout behavior. Add a test that keeps a control reader open without replying, then checks that initialization returns `AckTimeout`, sends no `GetIntegrationMode`, and frees its buffers. This would catch a return of the extra wait or a leak from the failed connection.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Skips runner probing when a leftover control FIFO has no reader.

  • Hook startup skips stale runner FIFOs without waiting.
  • A silent runner now ends the probe after one timeout.

not-matthias explicitly intends version timeouts to stop the candidate instead of continuing to GetIntegrationMode; that behavior is not reported as a defect.

Reviews (1) · Last reviewed commit: "fix(fifo): skip runner probing when the ..." · Reviewed by Greptile

Comment thread src/instruments/fifo_instrument.zig Resolved
FIFOs left in /tmp by an exited runner made instrument_hooks_init() block
for ~4 s before falling back to no instrument. Pipe.openPipe opens the
FIFOs O_RDWR, which succeeds without a peer, so stale files looked like a
live runner and both FIFO instruments waited for two 1 s ack timeouts.

RunnerFifo.init now probes the control FIFO with a non-blocking O_WRONLY
open, which fails with ENXIO when no process reads it, and returns
error.NoRunner. A live runner holds the FIFO open, so it is unaffected.
validate_protocol_version also propagates AckTimeout instead of
continuing into GetIntegrationMode, and FifoInstrument closes the FIFOs
on that error. dist/core.c is regenerated.

Swallowing AckTimeout (1460da1) was only meant to avoid exit(1) without a
runner; Instrument.init already falls back to the no-op instrument.

Fixes #36
GCC 15 defaults to C23, where zig.h expands zig_noreturn to [[noreturn]].
Zig's C backend emits `static zig_noreturn void f(...)`, and a C23
attribute after `static` is a syntax error, so dist/core.c no longer
compiled without an explicit -std. The Bazel example (no -std flag)
started failing once ubuntu-latest moved to GCC 15.

release.py now rewrites `static|zig_extern zig_noreturn` to put
zig_noreturn first, which is valid for every expansion in zig.h
(_Noreturn, __attribute__((noreturn)), __declspec(noreturn)).
@not-matthias
not-matthias force-pushed the cod-4460-fix-fifo-issues-reported-by-firefox branch from d317a2f to b8a85ec Compare November 26, 2026 10:59

@lvaroqui lvaroqui left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OLGTM 🙂

Comment thread scripts/release.py
# Zig's C backend mangles struct names (e.g. instrument_hooks_InstrumentHooks__547),
# and there's no way to control this from Zig source. Replace with the stable
# name from core.h so that core.c can be included alongside core.h without
# type conflicts.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this comment should probably move just above the replacement it describes

@not-matthias
not-matthias merged commit b8a85ec into main Nov 26, 2026
52 checks passed
@not-matthias
not-matthias deleted the cod-4460-fix-fifo-issues-reported-by-firefox branch November 26, 2026 15:09
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.

Init blocks 4 s when stale runner FIFOs exist without a reader

2 participants