#!/usr/bin/env bash set -euo pipefail # Run Larson with AddressSanitizer reliably for 4T by preloading libasan + HAKMEM ASan .so # Rationale: some environments fail to reserve ASan shadow when running a fully # sanitized binary for multi‑thread runs. Preloading the ASan runtime and the # allocator .so while using an unsanitized larson_system binary avoids those # mapping conflicts while still sanitizing allocator code paths. threads=${1:-4} sleep_sec=${2:-10} min_size=${3:-8} max_size=${4:-128} chunks_per_thread=${5:-1024} rounds=${6:-1} seed=${7:-12345} echo "[build] libhakmem_asan.so and larson_system" make -j asan-shared-alloc larson_system >/dev/null export LSAN_OPTIONS=${LSAN_OPTIONS:-detect_leaks=0} # Find libasan from the active toolchain libasan_path=$(gcc -print-file-name=libasan.so) if [[ ! -f "$libasan_path" ]]; then echo "[error] libasan.so not found via gcc -print-file-name" >&2 exit 1 fi export LD_PRELOAD="${libasan_path}:$PWD/libhakmem_asan.so" echo "[run] LD_PRELOAD set to: $LD_PRELOAD" cmd=("./larson_system" "$sleep_sec" "$min_size" "$max_size" "$chunks_per_thread" "$rounds" "$seed" "$threads") echo "[run] ${cmd[*]}" "${cmd[@]}"