Files
hakmem/scripts/verify_fast_cap_0_bug.sh

68 lines
2.1 KiB
Bash
Raw Normal View History

#!/bin/bash
# Verification script for FAST_CAP=0 SEGV bug
# Usage: ./scripts/verify_fast_cap_0_bug.sh
set -e
echo "============================================"
echo "FAST_CAP=0 SEGV Bug Verification"
echo "============================================"
echo ""
# Build with debug if needed
if [ ! -f libhakmem.so ]; then
echo "[Step 1] Building libhakmem.so..."
make clean && make
echo ""
fi
echo "[Step 2] Single-threaded test (should PASS)..."
HAKMEM_TINY_FAST_CAP=0 \
HAKMEM_LARSON_TINY_ONLY=1 \
HAKMEM_TINY_USE_SUPERSLAB=1 \
timeout 5 ./larson_hakmem 2 8 128 1024 1 12345 1 && echo "✓ PASSED" || echo "✗ FAILED"
echo ""
echo "[Step 3] Multi-threaded test (expected to CRASH)..."
HAKMEM_TINY_FAST_CAP=0 \
HAKMEM_LARSON_TINY_ONLY=1 \
HAKMEM_TINY_USE_SUPERSLAB=1 \
HAKMEM_TINY_TRACE_RING=1 \
timeout 5 ./larson_hakmem 2 8 128 1024 1 12345 4 2>&1 | tee /tmp/hakmem_crash.log && echo "✓ PASSED (unexpected!)" || echo "✗ CRASHED (expected)"
echo ""
echo "[Step 4] Checking Debug Ring output..."
if grep -q "remote_drain" /tmp/hakmem_crash.log; then
echo "✓ remote_drain events found (Fix is working!)"
else
echo "✗ NO remote_drain events (confirms diagnosis)"
fi
echo ""
echo "[Step 5] Checking for remote_push events..."
if grep -q "remote_push" /tmp/hakmem_crash.log; then
echo "✓ remote_push events found (cross-thread frees happening)"
else
echo "✗ NO remote_push events (unexpected)"
fi
echo ""
echo "[Step 6] Testing with FAST_CAP=64 (should PASS)..."
HAKMEM_TINY_FAST_CAP=64 \
HAKMEM_LARSON_TINY_ONLY=1 \
HAKMEM_TINY_USE_SUPERSLAB=1 \
timeout 5 ./larson_hakmem 2 8 128 1024 1 12345 4 && echo "✓ PASSED" || echo "✗ FAILED (unexpected!)"
echo ""
echo "============================================"
echo "Verification Complete"
echo "============================================"
echo ""
echo "Expected results:"
echo " - Single-thread: PASS"
echo " - Multi-thread FAST_CAP=0: CRASH (no remote_drain)"
echo " - Multi-thread FAST_CAP=64: PASS"
echo ""
echo "See /tmp/hakmem_crash.log for crash details"
echo "See FAST_CAP_0_SEGV_ROOT_CAUSE_ANALYSIS.md for full analysis"