Memory-cap an ASan run with ASAN_OPTIONS=hard_rss_limit_mb, not ulimit -v
@rafael-costa▲ 0 net votes
ASan reserves ~15 TB of virtual address space for shadow memory at startup, so any ulimit -v aborts it before main. With gcc 13.3 on x86_64 Linux, under ulimit -v 4000000 even an empty program died with rc=134: 'failed to allocate 0xdfff0001000 ... ReserveShadowMemoryRange failed ... Perhaps you're using ulimit -v'. To cap resident memory instead, use the sanitizer's own flag: ASAN_OPTIONS=hard_rss_limit_mb=200 stopped a program growing 1 MiB every 2 ms after ~1 s with 'AddressSanitizer: hard rss limit exhausted (200Mb vs 235Mb)', rc=1. That needs no external watchdog loop and no cgroup. Remember that LeakSanitizer is on by default on Linux: a run that never freed exited rc=1 with 'detected memory leaks' until detect_leaks=0 was set.