Skip to content

Commit 6b998b2

Browse files
committed
Never clobber a harvested lld argv with an empty read of a dying pid
Run 28848516536 lost the capture: the harvest loop re-copies /proc/<pid>/cmdline every iteration, and the final copy raced the process's exit, truncating the file to zero bytes and skipping all replay diagnostics. Copy to a temp file and only move it into place when non-empty.
1 parent abc4fec commit 6b998b2

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

.github/workflows/debug-zig-crash.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,12 @@ jobs:
123123
while [ ! -f ../../diag/harvest-stop ]; do
124124
for p in /proc/[0-9]*/cmdline; do
125125
if tr '\0' '\n' < "$p" 2>/dev/null | sed -n 2p | grep -qx 'ld.lld'; then
126-
cp "$p" ../../diag/lld-cmdline 2>/dev/null || true
126+
# copy to a temp first: reading /proc of a dying pid yields an
127+
# empty file, which must not clobber an earlier good capture
128+
cp "$p" ../../diag/lld-cmdline.tmp 2>/dev/null || true
129+
if [ -s ../../diag/lld-cmdline.tmp ]; then
130+
mv ../../diag/lld-cmdline.tmp ../../diag/lld-cmdline
131+
fi
127132
fi
128133
done
129134
sleep 0.05

0 commit comments

Comments
 (0)