Repository navigation
Conversation
…ssed `read` installs the run's deadline as its own kernel read deadline, so it can wake and return status 142 just before the context timer sets ctx.Err(). The post-builtin check only looked at ctx.Err(), so the script carried on and Run returned nil: a run that hit its deadline reported success. The check now also treats a passed ctx.Deadline() as expired and stops the run with context.DeadlineExceeded, for every builtin. It waits up to 100ms for the context timer to publish ctx.Err(), so callers that check the context after Run returns see it cancelled. Found by Jacob Hayes with patina (https://github.com/JacobHayes/patina). Environment: Datadog workspace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Windows pipes have no read deadlines, so read waits on ctx.Done() there and cannot race ahead of the context; the test context never fires Done. Environment: Datadog workspace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
A run that hit its deadline could report success.
readinstalls the run's deadline as its own kernel read deadline, so it can wake and return status 142 just before the context timer setsctx.Err(). The post-builtin check inRunner.callonly looked atctx.Err(), so the script carried on (read x; echo afterprintedafter) andRunreturned nil.The check now also treats a passed
ctx.Deadline()as expired and stops the run withcontext.DeadlineExceeded. It applies to every builtin, so others that race the same way are covered too. It waits up to 100ms (deadlineGrace) for the context timer to publishctx.Err(), so callers that check the context afterRunreturns see it cancelled; without that, the while/until pentest and fuzz tests ininterp/tests, which assert exactly that, failed.Credit
Found by Jacob Hayes with his deterministic-simulation tool patina (finding #4: deadline-ignored oracle with µs deadlines, about 4.9k runs; racy natively, about 3 in 2,000 at GOMAXPROCS=1, deterministic under patina at a 13 µs deadline). Findings thread: https://dd.slack.com/archives/D0AC8RLB21J/p1793475631273749
Tests
TestReadHittingRunDeadlineIsNotSuccess(interp/timeout_test.go) makes the race deterministic:read x; echo afteron a pipe that never sends, under a context that reports a 20ms deadline but never fires. It assertsRunreturnsDeadlineExceededandafterisn't printed.GOMAXPROCS=1.go test ./...passes exceptTestPSPentestLargePIDListDoesNotHanginbuiltins/ps, which fails the same way on clean main on this host.This touches the same block of
interp/runner_exec.goas #708 (write errors); whichever lands second gets a rebase.🤖 Generated with Claude Code