Repository navigation
fix(push): read procfs entries whole to avoid read buffer cross-talk - #61
Merged
Merged
Conversation
Read a live pid and an absent pid through read_process_stat and read_process_uid under `set -e` and `set +e`, in `if !` and `||` call positions, and assert that control flow and the caller's errexit state survive. Narrow the helper comments: the substitution only avoids the observed cross-read path, and errexit is toggled because a failed $(<file) open can bypass if/|| on Bash 5.2.
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.
问题
tests/test-push.sh在 Debian 13 上约 1/10 偶发失败:存活 worker 被父进程
prune_active_workers误判为身份不可信,BATCH_WORKER_FAILED=true后整批提前终止。定位
/proc/<pid>/stat可读、fd 目标正确、位置为 0,但read_process_stat连续拿到的是 status 文件的行(Gid:/FDSize:/Groups:/ …),格式校验失败,PROC_START保留上一次读取的值。exec {fd}</proc/...; read -r ... <&fd逐行读取;read_process_uid读取 status 时提前break,未消费的缓冲会在后续 stat 读取中被取出。修改
read_process_stat/read_process_uid改为整文件读取,避免逐行read的跨读取缓冲路径。$(<file)在 Bash 5.2 下打开失败可能绕过if/||终止 shell,故读取期间按$-快照临时关闭 errexit,读完恢复。验证
tests/test-push.sh10 次串行 1 次失败;失败样本与插桩日志见 hkhkt/root/workdir/minis/flake-20261024/logs/target-2249/(诊断环境,未入库)。tests/test-push.sh连续 20 次 rc=0,每次 342 PASS,77.7–78.9 s(基线 76–77 s)。if !与||四种失败调用位、前后$-状态一致;套件 348 PASS。变异(移除set +e)会让该用例失败。已知限制
set +e是函数级 shell 状态,信号 trap 可能在该窗口看到 errexit 关闭;窗口仅一次读取。