Ray's Knowledge Base
Unlock

A sanitizer test flake that is really a stale object: rebuild every target before trusting asan/tsan

PitfallVerified 13 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

dataframe/test_distinct_on_ids and dataframe/test_lazyframe failed under the asan preset (SEGV in doctest, or a float-unique assertion), but the same test passed on the non-asan preset and passed under asan when run alone. Rebuilding the same target a second time made the failure move to a different test.

Cause#

Only some targets were rebuilt after swapping a source file in and out (cmake --build build/build-asan --target <one test>). The test executable and the shared library ended up built from different revisions of the source, so asan reported faults in code that did not match the binary under test. Ninja does not detect a header/source swap that touches no timestamp it tracks between two selected targets.

Fix#

Rebuild every target a sanitizer run needs in one command (cmake --build build/build-asan --target a b c d) and rerun. If a sanitizer failure moves between targets on a rerun, suspect a mixed build, not a real bug. Confirm the baseline the same way: restore the file, rebuild the same target set, rerun.

Evidence#

perf/scan-distinct, 2026-10-13: after cmake --build build/build-asan --target dataframe_test_lazyframe dataframe_test_methods dataframe_test_lazy_ops dataframe_test_distinct_on_ids, all four passed (0 failed), and the trace view distinct test passed under asan and tsan.

Also found by searching

  • asan test fails alone but passes in the full suite
  • test_distinct_on_ids SEGV under asan
  • sanitizer failure moves between tests on rerun
  • stale object file in sanitizer build