Fix for the 2026-10-25 host freeze (an uncaught iostream exception on a /proc read aborted the daemon; its core dump deadlocked with the exec guard): non-throwing /proc reads, crash handlers that release fanotify permission fds, guarded thread entries, from_chars parsing. Adds the io fault-injection seam with property tests, source invariant checks (R1-R6) with self-test fixtures, libFuzzer targets and seeds (including I/O-fault fuzzing), the fold changed-files scan scripts and the agent workflow docs (CLAUDE.md, prompts). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
61 lines
3.4 KiB
Bash
Executable file
61 lines
3.4 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Runs inside fold-linux-validate (LLVM 19), resource-capped by the caller
|
|
# (scripts/fold_changed.sh).
|
|
# /fold and /strawberry are read-only; /cache persists the fold build and
|
|
# conan cache across runs; results go to /out.
|
|
set -euo pipefail
|
|
JOBS=2
|
|
export CONAN_HOME=/cache/conan
|
|
|
|
if ! dpkg -s libyara-dev >/dev/null 2>&1; then
|
|
apt-get update -qq && apt-get install -y -qq --no-install-recommends \
|
|
libbpf-dev libssl-dev libyara-dev libcurl4-openssl-dev libarchive-dev g++ >/dev/null
|
|
fi
|
|
|
|
FOLD=$(find /cache/fold-rel -maxdepth 3 -type f -name fold -perm -u+x 2>/dev/null | head -1 || true)
|
|
if [ -z "$FOLD" ]; then
|
|
rsync -a --exclude '/build' --exclude '/.git' --exclude '*.o' --exclude '*.log' --exclude '/infer-out' /fold/ /cache/fold-src/
|
|
cd /cache/fold-src
|
|
[ -f "$CONAN_HOME/profiles/default" ] || conan profile detect --force >/dev/null
|
|
if [ ! -f /cache/fold-rel/conan_meson_native.ini ]; then
|
|
conan install . --output-folder=/cache/fold-rel --build=missing -s build_type=Release \
|
|
-o build_tests=False -c tools.build:jobs=$JOBS >/out/conan.log 2>&1
|
|
fi
|
|
Z3_PC=$(ls /usr/lib/*/pkgconfig/z3.pc | head -1); ln -sf "$Z3_PC" /cache/fold-rel/z3.pc
|
|
[ -f /cache/fold-rel/build.ninja ] || meson setup /cache/fold-rel --native-file /cache/fold-rel/conan_meson_native.ini \
|
|
--wrap-mode=default -Dcpp_std=c++23 -Dbuild-tests=false -Dghidra=disabled -Dcapstone=disabled \
|
|
-Drust-frontend=false -Dswift-frontend=false \
|
|
-Dllvm-config-path="$LLVM_CONFIG" >/out/fold-setup.log 2>&1 || { tail -40 /out/fold-setup.log; exit 1; }
|
|
meson configure /cache/fold-rel -Drust-frontend=false -Dswift-frontend=false >/dev/null
|
|
meson compile -C /cache/fold-rel -j $JOBS >/out/fold-compile.log 2>&1 || { grep -E "error" -A3 /out/fold-compile.log | head -40; exit 1; }
|
|
FOLD=$(find /cache/fold-rel -maxdepth 3 -type f -name fold -perm -u+x | head -1)
|
|
fi
|
|
echo "fold: $FOLD"
|
|
|
|
# Compile database only (no Strawberry build needed for source analysis).
|
|
rsync -a --delete --exclude '/builddir' --exclude '/build' --exclude '/.git' --exclude '/.ccache' /strawberry/ /cache/strawberry/
|
|
rm -rf /cache/sb
|
|
cd /cache/strawberry
|
|
CC=gcc CXX=g++ meson setup /cache/sb -Denable_tests=false -Denable_app=disabled -Denable_mcp=enabled >/out/sb-setup.log 2>&1 \
|
|
|| { tail -30 /out/sb-setup.log; exit 1; }
|
|
|
|
# Scan only Strawberry's own TUs: fold's --exclude-glob does not match the
|
|
# compile database's relative "../strawberry/third_party/..." paths, so filter
|
|
# here. FOLD_FILES (space-separated repo paths) narrows further to those TUs.
|
|
DB=/cache/sb/scan_commands.json
|
|
python3 - /cache/sb/compile_commands.json "$DB" ${FOLD_FILES:-} <<'PY'
|
|
import json, sys
|
|
db, out, files = sys.argv[1], sys.argv[2], sys.argv[3:]
|
|
entries = [e for e in json.load(open(db))
|
|
if "/third_party/" not in e["file"] and "/tests/" not in e["file"]]
|
|
if files:
|
|
entries = [e for e in entries if any(e["file"].endswith("/" + f) for f in files)]
|
|
json.dump(entries, open(out, "w"))
|
|
print(f"fold: {len(entries)} translation unit(s) to scan")
|
|
PY
|
|
DETECTORS="${FOLD_DETECTORS:-null-deref,div-by-zero,int-overflow,oob,int-truncation,taint-track,uninit-read,use-after-move,iterator-invalidation,exception-escape}"
|
|
"$FOLD" scan --mode source --compile-db "$DB" \
|
|
--exclude-glob '*/third_party/*' --exclude-glob '*/tests/*' \
|
|
--detectors $DETECTORS --processes $JOBS --budget-seconds 300 --per-query-ms 2000 \
|
|
--format json --output /out/fold.json 2>/out/fold.stderr || echo "fold exit=$?"
|
|
echo "scan done"
|