Files
Sylpheed/tools/run-canary-native-safe.sh
Claude 884a2c3944
Some checks failed
CI / Native — linux (pull_request) Failing after 1h3m36s
CI / WASM — Web (pull_request) Successful in 24m29s
CI / Formatting (pull_request) Successful in 27s
fix(canary): point the launchers at a binary that exists and is instrumented
`/sylph-canary` was dead at both ends, measured rather than assumed:

  * `run-canary-safe.sh` runs the Wine build and defaults to
    `xenia_canary_i2d.exe`, which DOES NOT EXIST. The `xenia_canary.exe` that
    does (2026-06-19) has ZERO strings for `audit_61_branch_probe_pcs` and zero
    for `RE-INPUT`/`RE-DRAW` -- it predates all our instrumentation, and
    refreshing it needs the clang-cl + xwin toolchain on `cross-build-wine`.
  * both native launchers defaulted to
    `xenia-canary-native/build/bin/Linux/Release/xenia_canary`. That directory
    does not exist on this workspace -- the checkout is `xenia-canary/` -- and
    Release is not even a target in that build tree (`ninja -n` lists 0 steps),
    so its binary is frozen at 2026-08-28, before the probe.

Native launchers now default to
`xenia-canary/build/bin/Linux/Checked/xenia_canary`: the config this tree can
actually build, rebuilt today with the audit_61 probe (Canary PR #2), verified
by `strings` -- audit_61 8 hits, RE-INPUT/RE-DRAW 4. `Checked` is optimised WITH
assertions, which is what a behavioural reference should be: a bad state stops
loudly rather than being sampled.

The Wine launcher now ABORTS with the reason and points at the native one,
instead of failing somewhere downstream on a missing file.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-20 21:00:13 +02:00

109 lines
5.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# SAFE launcher for the NATIVE Linux Xenia-Canary build on THIS box.
#
# Same safety contract as run-canary-safe.sh (the Wine/Windows variant): the AMD
# GPU + GPU-accelerated VS Code means a hardware-Vulkan render CRASHES VS Code.
# This wrapper forces software Vulkan (lavapipe/llvmpipe) IN THE SAME process and
# HARD-REFUSES to launch if any hardware Vulkan device is still visible.
#
# Difference vs run-canary-safe.sh: runs the native ELF directly (NO wine).
#
# Usage: tools/run-canary-native-safe.sh [seconds]
# env: CANARY_BIN override binary (default = worktree Release build)
# CANARY_EXTRA_ARGS space-separated extra cvars (values w/o spaces)
# Output: /tmp/canary_native.stdout (+ xenia.log in the binary dir). Prints rc + ADV.wmv hits.
set -u
# --- force software Vulkan, belt-and-suspenders across loader/driver variants ---
export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/lvp_icd.json
export VK_DRIVER_FILES=/usr/share/vulkan/icd.d/lvp_icd.json
export MESA_VK_DEVICE_SELECT=llvmpipe
export LIBGL_ALWAYS_SOFTWARE=1
# --- keep background runs SILENT *without* killing the audio system ---
# DO NOT use --apu=nop: with no audio system the guest's XAudio render client is
# NULL and Project Sylpheed derefs null+0x3C at PC 0x824D7C40 -> a FALSE boot
# crash that never happens in interactive runs. Instead keep the ALSA apu ALIVE
# and route PCM "default" to the null device (see asound-null.conf): silent, but
# snd_pcm_open succeeds so the guest is happy. --mute does NOT silence ALSA.
export SDL_AUDIODRIVER=dummy
export ALSA_CONFIG_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/asound-null.conf"
[ -f "$ALSA_CONFIG_PATH" ] || { echo "ABORT: asound-null.conf missing next to script"; exit 4; }
# Paths derive from where this script sits — see the note in run-canary-safe.sh.
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
WORKSPACE="$(cd "$HERE/../.." && pwd)"
# 🔴 THE INSTRUMENTED BINARY IS THE `Checked` ONE, and it is the only config this
# build tree can produce: `ninja -n bin/Linux/Release/xenia_canary` lists ZERO
# steps, so Release is not a target here and its binary still dates from
# 2026-08-28, before the audit_61 probe existed. Pointing at Release therefore
# runs an oracle with no probe and no way to refresh it.
#
# The old default named `xenia-canary-native/`, a directory that does not exist
# on this workspace at all -- the checkout is `xenia-canary/`.
#
# `Checked` is optimised WITH assertions, which is what you want from a
# behavioural reference: a bad state stops loudly instead of being sampled.
BIN_DEFAULT="$WORKSPACE/xenia-canary/build/bin/Linux/Checked/xenia_canary"
BIN_EXE="${CANARY_BIN:-$BIN_DEFAULT}"
ISO="${SYLPHEED_ISO:-$WORKSPACE/Project Sylpheed - Arc of Deception (USA, Europe) (En,Ja).iso}"
[ -f "$ISO" ] || { echo "ABORT: no ISO at '$ISO' — set \$SYLPHEED_ISO"; exit 4; }
SECS="${1:-95}"
[ -x "$BIN_EXE" ] || { echo "ABORT: native binary not found/executable: $BIN_EXE"; exit 4; }
# --- HARD PRE-FLIGHT GATE: only proceed if Vulkan exposes software devices ONLY ---
devs="$(vulkaninfo --summary 2>/dev/null | grep -i deviceName || true)"
if echo "$devs" | grep -qiE 'radv|amd|radeon|nvidia|geforce|intel\b'; then
echo "ABORT(pre-flight): a HARDWARE Vulkan device is still visible -> refusing (would crash VS Code):"
echo "$devs"
exit 3
fi
if ! echo "$devs" | grep -qiE 'llvmpipe'; then
echo "ABORT(pre-flight): llvmpipe not visible; lavapipe ICD missing? devs=[$devs]"
exit 3
fi
echo "pre-flight OK: software-only Vulkan -> $devs"
# --- clean slate ---
pkill -x xenia_canary 2>/dev/null; pkill -x Xvfb 2>/dev/null; sleep 1
Xvfb :99 -screen 0 1280x720x24 -nolisten tcp >/tmp/xvfb.log 2>&1 &
XVFB=$!
sleep 2
export DISPLAY=:99
cd "$(dirname "$BIN_EXE")" || { echo "ABORT: bin dir missing"; kill "$XVFB" 2>/dev/null; exit 4; }
rm -f xenia.log
# Real ALSA apu (routed to null sink via ALSA_CONFIG_PATH) so the guest gets a
# valid render client; --mute belt-and-suspenders. NEVER add --apu=nop here.
args=(--log_level=3 --mute=true)
if [ -n "${CANARY_EXTRA_ARGS:-}" ]; then
read -ra EXTRA <<< "$CANARY_EXTRA_ARGS"
args+=("${EXTRA[@]}")
fi
echo "launch (native, sw-vulkan, SILENT null-ALSA, ${SECS}s): $(basename "$BIN_EXE") ${args[*]}"
# -k 5: xenia catches SIGTERM and can hang on shutdown; force-KILL 5s later.
timeout -k 5 "$SECS" "$BIN_EXE" "$ISO" "${args[@]}" >/tmp/canary_native.stdout 2>&1
rc=$?
pkill -x xenia_canary 2>/dev/null; kill "$XVFB" 2>/dev/null; pkill -x Xvfb 2>/dev/null
# --- trustworthy boot-health verdict (NOT log-line-count, NOT rc) ---
# A healthy boot reaches actual content: title loaded + XMA audio decoding + NO
# host-exception fault loop. rc=137 is EXPECTED (timeout -k kill), not a failure.
faults=$(grep -ac 'Access Violation' /tmp/canary_native.stdout 2>/dev/null)
gthrow=$(grep -ac 'GUEST-THROW' xenia.log 2>/dev/null)
title=$(grep -ac 'Title name: PROJECT SYLPHEED' xenia.log 2>/dev/null)
xma=$(grep -acE 'XmaContext|Processing context' xenia.log 2>/dev/null)
echo "rc=$rc logsize=$(wc -c < xenia.log 2>/dev/null)"
echo "boot-health: title=$title xma=$xma faults=$faults guest_throw=$gthrow"
if [ "$title" -ge 1 ] && [ "$xma" -ge 100 ] && [ "$faults" -eq 0 ] && [ "$gthrow" -eq 0 ]; then
echo "VERDICT: HEALTHY (reached content, no crash)"
elif [ "$gthrow" -ge 1 ]; then
echo "VERDICT: GUEST-THROW CRASH (the real bug) -- see GUEST-THROW lines in xenia.log"
elif [ "$faults" -ge 1 ]; then
echo "VERDICT: FAULT (host access-violation loop) -- crash PC:"
grep -aoE 'PC: 0x[0-9A-Fa-f]+' /tmp/canary_native.stdout | sort | uniq -c | head -3
else
echo "VERDICT: INCOMPLETE (did not reach content in ${SECS}s -- raise timeout?)"
fi