Repository navigation
fix(tool): reject workspace named pipes before opening - #1979
Conversation
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
chaojixinren
left a comment
There was a problem hiding this comment.
Defensive fix for a rare but real hang on FIFOs. Only adds an early file-type check before opening — no impact on normal file reads. Tests cover FIFO paths and regular symlinks. Safe to merge. LGTM.
|
@Afloat16 Thanks for covering both FIFO paths and symlinks to them. Could we narrow the guard in The distinction matters on Windows: Go 1.26.10 marks unrecognized reparse tags as Checking specifically for |
|
Implemented in 49d1e70. The guard now checks All six real Linux FIFO cases are retained. A small classification table accepts
|
|
@Afloat16 Thanks for updating the FIFO check. I’m planning to run the benchmark for this PR tonight and would like to test it against the latest If you don’t have time, just let me know here. Allow edits from maintainers is already enabled, so there’s no setting to change; I can take care of the rebase before the benchmark. |
49d1e70 to
2071ccc
Compare
|
Rebased onto the current Both original commits replayed without conflict; Validation on the rebased tree with Go 1.26.10 on Linux: The new-head hosted checks have now passed: Linux tests, Windows tests, all five cross-compilation targets, and all CodeQL analyses/results. CI run. |
Description
A workspace path can resolve to a FIFO inside the repository. Both full-file reads and the line-window reader open that path before their read loop can observe cancellation. A review tool call therefore hangs on a named pipe even after its context deadline expires.
Check the resolved workspace entry for
os.ModeNamedPipebefore opening it. The check runs after the existing symlink and canonical repository-containment checks, so it also covers an in-repository symlink to a FIFO. Other mode flags, includingos.ModeIrregularalone, are not rejected by this guard.Type of Change
How Has This Been Tested?
The Linux regression creates a real named pipe and a symlink to it, then invokes
FileReader.Read,ReadLinesand the publicfile_readtool in isolated child processes. Each read has a 50 ms context deadline, and the parent terminates a regression after 2 seconds so the test does not leave a blocked goroutine behind. All six cases remain in the test and return a named-pipe error with the fix. Positive controls read a regular file and an in-repository symlink through both the full-file and tool paths.The mode-classification regression accepts a regular mode and
ModeIrregularalone, and rejectsModeNamedPipeboth alone and combined withModeIrregular. TheModeIrregularcase failed with the previous!IsRegular()guard and passes with the narrowed guard. This is a mode-classification test; no live OneDrive checkout was used.Validation of rebased commit
2071cccf6dd3a4b3e31bb689dddac922104abc5b(tree353323fa1a7037e7b0d53566d8ead4dcf355ce2a), using Go 1.26.10 on Linux. The two original commits were replayed unchanged ontomainat39515dca6161fb7fd176d87704b2b10e5f7a0c36;git range-diffmarks both patches equal.make check— passed.make test PACKAGES="./internal/tool ./internal/diff"— passed, including the race detector, all six FIFO cases, mode classifications and regular-file controls.make coverage— the complete unit-test suite passed, with 91.5% overall coverage (90% required).make build— passed.git diff --check— passed.The inherited telemetry sampler was explicitly set to
always_onfor the test suite. The requiredocr review --audience agent --background "..."command was attempted, but could not start because no LLM endpoint is configured in the environment.This handles named pipes present at resolution time. It does not claim to eliminate concurrent path-replacement races or provide cancellation for every filesystem operation.
Checklist
Primary contributor and submitting author: Afloat16.
AI/LLM disclosure required by this repository: OpenAI ChatGPT (GPT-6 Astra Pro).