Repository navigation
fix(runregistry): keep runs whose pid we may not signal - #4982
TDnorthgarden wants to merge 1 commit into
Conversation
| return false | ||
| // ERROR_ACCESS_DENIED means the process exists but is protected | ||
| // (elevated or AV-guarded); it is alive. | ||
| return errors.Is(err, windows.ERROR_ACCESS_DENIED) |
There was a problem hiding this comment.
[blocking] Please add a Windows regression test that makes OpenProcess return ERROR_ACCESS_DENIED and asserts pidAlive still returns true. TestList_RealLiveness probes the current process and an exited child; neither exercises access denial. The Windows suite would still pass if this branch returned false and Registry.List resumed deleting records for protected live processes.
There was a problem hiding this comment.
The Windows regression is added in f164b6c (force-pushed): openProcess is now a variable so TestPidAliveAccessDenied can make it return ERROR_ACCESS_DENIED and assert pidAlive returns true — pinning exactly the branch you flagged, while TestList_RealLiveness stays as-is.
The Windows test binary cross-compiles and vets clean for windows/amd64 locally; test-windows CI will execute it. Marking the PR ready for review.
|
👋 We’ve requested changes on this PR. Once you’ve addressed the feedback, please mark it ready for review. |
pidAlive treated a failed signal probe as proof the process was dead. On Unix, kill(pid, 0) returns EPERM when the process exists but belongs to another user (or root), so a live run was judged dead and List deleted its record — making it invisible to List/Find/Latest on multi-user hosts, shared data dirs, and containers. Windows had the same shape: OpenProcess returns ERROR_ACCESS_DENIED for protected processes (elevated or AV-guarded), which was also treated as dead. Treat EPERM (and ERROR_ACCESS_DENIED on Windows) as alive: it proves existence, only inspection is refused. The probes are variables (signalProcess, openProcess) so each platform's permission-denied branch is pinned by a regression test without needing a second user or a protected process. Fixes docker#4981 Signed-off-by: Aucoto Zhang <tdnorthgarden@gmail.com>
13fc176 to
f164b6c
Compare
Problem
pidAlivetreats a failed signal probe as proof the process is dead. On Unix,kill(pid, 0)returnsEPERMwhen the process exists but belongs to another user (or root), so a live run was judged dead andRegistry.Listdeleted its record (pkg/runregistry/registry.go:123-126) — making the run invisible toList/Find/Lateston multi-user hosts, shared data directories, and containers.Windows has the same shape:
OpenProcessreturnsERROR_ACCESS_DENIEDfor protected processes (elevated or AV-guarded), which was also treated as dead.Fix
EPERMas alive on Unix: the probe proves the process exists, only inspection is refused. Same forERROR_ACCESS_DENIEDon Windows.kill(pid, 0)probe is now an injectable variable so the permission-denied branch can be exercised without a second user (TestPidAlivePermissionDenied);TestPidAliveRejectsNonPositivekeeps the 0/negative guard.Fixes #4981