interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / evidence / own-gpu-driver / rung2 / reproduce-pipefail.sh

72 lines · 2433 bytes Raw Blame History
1#!/usr/bin/env bash
2# reproduce-pipefail.sh: deterministic reproduction of the SIGPIPE (exit 141)
3# race in window1-package.sh when using `tail | head` under `set -eo pipefail`,
4# and verification that `dd if=... of=... bs=64k iflag=skip_bytes,count_bytes`
5# exits 0 and produces byte-identical slices without pipes.
6set -eu
7FW=${FW:-/lib/firmware/nvidia/580.173.02/gsp_ga10x.bin}
8T=$(mktemp -d /tmp/repro-pipefail.XXXXXX)
9trap 'rm -rf "$T"' EXIT
10
11if [[ -r "$FW" ]]; then
12 SRC="$FW"
13 off=64
14 size=74969088
15 echo "Using real GSP firmware: $FW (size $(stat -c %s "$FW") bytes)"
16else
17 SRC="$T/synthetic.bin"
18 dd if=/dev/urandom of="$SRC" bs=1M count=16 status=none
19 off=64
20 size=8388608
21 echo "Using synthetic binary payload: $SRC (size $(stat -c %s "$SRC") bytes)"
22fi
23
24echo "--- 1. Demonstrating SIGPIPE (exit 141) with tail | head under pipefail ---"
25old_141_count=0
26trials=20
27for i in $(seq 1 "$trials"); do
28 rc=0
29 (
30 set -euo pipefail
31 tail -c +$((off + 1)) "$SRC" | head -c "$size" > /dev/null
32 ) || rc=$?
33 if [[ $rc -eq 141 ]]; then
34 old_141_count=$((old_141_count + 1))
35 fi
36done
37echo "tail | head under pipefail: $old_141_count / $trials runs exited with 141 (SIGPIPE)"
38
39echo "--- 2. Demonstrating exit 0 with dd (no pipe, direct seek and slice) ---"
40new_fail_count=0
41for i in $(seq 1 "$trials"); do
42 rc=0
43 (
44 set -euo pipefail
45 dd if="$SRC" of=/dev/null bs=64k iflag=skip_bytes,count_bytes skip="$off" count="$size" status=none
46 ) || rc=$?
47 if [[ $rc -ne 0 ]]; then
48 new_fail_count=$((new_fail_count + 1))
49 fi
50done
51echo "dd with skip_bytes,count_bytes: $new_fail_count / $trials failures (all passed with rc 0)"
52
53echo "--- 3. Verifying byte-for-byte identity against reference ---"
54python3 -c "
55with open('$SRC', 'rb') as f:
56 f.seek($off)
57 chunk = f.read($size)
58with open('$T/reference.bin', 'wb') as f:
59 f.write(chunk)
60"
61dd if="$SRC" of="$T/dd.bin" bs=64k iflag=skip_bytes,count_bytes skip="$off" count="$size" status=none
62
63cmp "$T/reference.bin" "$T/dd.bin"
64echo "BYTE-IDENTICAL: Reference and dd outputs match exactly ($size bytes)"
65
66if [[ $old_141_count -gt 0 && $new_fail_count -eq 0 ]]; then
67 echo "REPRODUCTION SUCCESS: tail|head exited 141; dd exited 0 with byte-identical output"
68 exit 0
69else
70 echo "REPRODUCTION FAILED unexpected counts: old_141=$old_141_count new_fail=$new_fail_count"
71 exit 1
72fi