Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.
C aiderastclaude-codecode-analysiscode-intelligencecodexcursorcypherdeveloper-toolsgemini-cligraph-visualizationkilocodeknowledge-graphmcpmcp-servermodel-context-protocolopencodesqlitetree-sitterwindsurf
test: keep ASan stack-use-after-return off outside the diag lane
Martin Vogelf8d8fcdefec1
diff --git a/scripts/test.sh b/scripts/test.shindex 1741f8a1d..54962bf04 100755--- a/scripts/test.sh+++ b/scripts/test.sh@@ -179,6 +179,18 @@ if [ "$SANITIZE_GIVEN" -eq 0 ] && [ "${MSYSTEM:-}" = "CLANGARM64" ]; thenMAKE_ARGS+=("SANITIZE=-fsanitize=undefined -fsanitize-trap=undefined -fstack-protector-strong -fno-omit-frame-pointer")fi+# ASan stack-use-after-return runs in the test-diag lane only (_test.yml and+# `make -f Makefile.cbm diag` set detect_stack_use_after_return=1). gcc's+# libasan turns it ON by default, and on aarch64 gcc 13/14 never clear a freed+# fake frame's in-use flag: past 8,192 frames per size class every instrumented+# call scans that flag array and the check stops detecting anything (gcc arm64+# ran `extraction` in 688 s, amd64 in 16 s). Off here; an explicit setting wins.+case "${ASAN_OPTIONS:-}" in+ *detect_stack_use_after_return*) ;;+ *) ASAN_OPTIONS="${ASAN_OPTIONS:+$ASAN_OPTIONS:}detect_stack_use_after_return=0" ;;+esac+export ASAN_OPTIONS+EXPECTED_SANITIZED=1if [ "$SANITIZE_GIVEN" -eq 1 ]; thencase "$SANITIZE_VALUE" indiff --git a/tests/test_venue_parity_contract.sh b/tests/test_venue_parity_contract.shindex 81e431a1e..cef82b33e 100755--- a/tests/test_venue_parity_contract.sh+++ b/tests/test_venue_parity_contract.sh@@ -24,10 +24,13 @@# 5. Interface probes — every entry must answer --help (exit 0, "Usage:")# and reject unknown flags with exit 2 + "Please consult --help." so an# agent can always discover exactly what a run will do.+# 6. Sanitizer runtime defaults — scripts/test.sh, not each venue, sets the+# ASan options every lane runs with (stack-use-after-return stays off+# unless a lane asks for it explicitly, as test-diag does).## Usage: tests/test_venue_parity_contract.sh [repo-root] (root override so# the suite can prove the contract FAILS on a violation, not just passes;-# layer 5 runs only against the real repo root).+# layers 5 and 6 run only against the real repo root).set -euo pipefail@@ -455,3 +458,63 @@ scripts/memwaste.shfiecho "interface probes OK ($(printf '%s' "$HELP_ENTRIES" | grep -c .) --help entries, $(printf '%s' "$STRICT_ENTRIES" | grep -c .) strict-flag entries)"fi++# ── Layer 6: sanitizer runtime defaults (real repo root only). Drives the REAL+# scripts/test.sh in --suites mode with a no-op `make` first on PATH and a+# probe standing in for the test-runner: the probe answers the build-config+# handshake, then records the ASAN_OPTIONS it inherited. Every case sets or+# unsets ASAN_OPTIONS itself, because this contract runs INSIDE test.sh, whose+# own export would otherwise leak in.+if [ -d "$ROOT/scripts" ] && [ -f "$ROOT/scripts/test.sh" ]; then+ asan_failures=0+ asan_tmp="$(mktemp -d)"+ trap 'rm -rf "$asan_tmp"' EXIT+ mkdir -p "$asan_tmp/bin" "$asan_tmp/build"+ printf '#!/usr/bin/env bash\nexit 0\n' > "$asan_tmp/bin/make"+ cat > "$asan_tmp/build/test-runner" <<'EOF'+#!/usr/bin/env bash+if [ "${1:-}" = "--build-config" ]; then+ printf 'sanitized=1 test_seams=1\n'+ exit 0+fi+printf '%s' "${ASAN_OPTIONS-<unset>}" > "$CBM_ASAN_PROBE_OUT"+EOF+ chmod +x "$asan_tmp/bin/make" "$asan_tmp/build/test-runner"++ # asan_case LABEL GIVEN WANT: GIVEN is the caller's ASAN_OPTIONS ("<unset>"+ # for none), WANT the exact value the runner must receive.+ asan_case() {+ local label="$1" given="$2" want="$3" seen rc+ rm -f "$asan_tmp/seen"+ (+ if [ "$given" = "<unset>" ]; then+ unset ASAN_OPTIONS+ else+ export ASAN_OPTIONS="$given"+ fi+ cd "$ROOT" && PATH="$asan_tmp/bin:$PATH" CBM_NO_CCACHE=1 \+ CBM_ASAN_PROBE_OUT="$asan_tmp/seen" \+ bash scripts/test.sh --suites probe "BUILD_DIR=$asan_tmp/build"+ ) >"$asan_tmp/log" 2>&1 && rc=0 || rc=$?+ seen="$(cat "$asan_tmp/seen" 2>/dev/null || printf '<runner not reached>')"+ if [ "$rc" -ne 0 ] || [ "$seen" != "$want" ]; then+ echo "SANITIZER DEFAULTS: $label: runner got ASAN_OPTIONS=[$seen], want [$want] (test.sh rc=$rc)" >&2+ sed 's/^/ /' "$asan_tmp/log" >&2+ asan_failures=1+ fi+ }++ asan_case "unset" "<unset>" \+ "detect_stack_use_after_return=0"+ asan_case "other options kept" "detect_leaks=1:halt_on_error=1" \+ "detect_leaks=1:halt_on_error=1:detect_stack_use_after_return=0"+ asan_case "explicit setting wins (test-diag)" \+ "detect_stack_use_after_return=1:strict_string_checks=1:detect_stack_use_after_scope=1" \+ "detect_stack_use_after_return=1:strict_string_checks=1:detect_stack_use_after_scope=1"++ if [ "$asan_failures" -ne 0 ]; then+ echo "VENUE PARITY CONTRACT VIOLATED — sanitizer runtime defaults failed (layer 6)" >&2+ exit 1+ fi+ echo "sanitizer runtime defaults OK (3 ASAN_OPTIONS cases through scripts/test.sh)"+fi