test_framework.h,test_incremental.c: detect MemorySanitizer builds

MemorySanitizer was absent from TF_SANITIZER_ACTIVE at tests/test_framework.h:38, so test_py_lsp_bench.c enforced its 150 ms native ceiling against a 270.28 ms instrumented run and test_incremental.c enforced its 2304 MiB production RSS ceiling against 3220 MiB of shadow/origin-inflated RSS.

Add __has_feature(memory_sanitizer) to the shared test-framework predicate and make incr_memory_instrumentation_active() reuse that predicate while retaining MallocScribble and Guard Malloc detection. Native latency and RSS ceilings remain unchanged; the runtime, allocation count, and asymptotic bounds are unaffected.

Verified by rebuilding build/c/test-runner with ASan/UBSan; py_lsp_bench passed at 32.29 ms; cs_lsp_bench passed at 15.63 ms; incremental/incr_full_index passed at 3876 ms with 1144 MiB RSS delta; and x86_64 Linux preprocessing selected TF_SANITIZER_ACTIVE=0 natively and __has_feature(memory_sanitizer)=1 with -fsanitize=memory.

Signed-off-by: Andrew Hundt <ATHundt@gmail.com>
This commit is contained in:
Andrew Hundt committed 2026-08-09 11:08:15 -04:00
1 parent 3562111d56
commit 9953c328d1
2 files changed
+5 -10

No files matched your search

+2 -1
View File
@@ -37,7 +37,8 @@
#endif
#if defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_THREAD__) || \
__has_feature(address_sanitizer) || __has_feature(thread_sanitizer)
__has_feature(address_sanitizer) || __has_feature(thread_sanitizer) || \
__has_feature(memory_sanitizer)
#define TF_SANITIZER_ACTIVE 1
#else
#define TF_SANITIZER_ACTIVE 0
+3 -9
View File
@@ -73,22 +73,16 @@ static const char *INCR_TEST_FASTAPI_TAG = "0.99.1";
static const char *INCR_TEST_FASTAPI_COMMIT = "dd4e78ca7b09abdf0d4646fe4697316c021a8b2e";
static const char *INCR_TEST_FASTAPI_DEFAULT_CACHE_NAME = "cbm-test-fastapi-0.99.1-cache";
#ifndef __has_feature
#define __has_feature(x) 0
#endif
static bool incr_memory_instrumentation_active(void) {
#if defined(__SANITIZE_ADDRESS__) || defined(__SANITIZE_THREAD__) || \
__has_feature(address_sanitizer) || __has_feature(thread_sanitizer)
return true;
#else
if (TF_SANITIZER_ACTIVE) {
return true;
}
const char *scribble = getenv("MallocScribble");
const char *pre_scribble = getenv("MallocPreScribble");
const char *guard_malloc = getenv("DYLD_INSERT_LIBRARIES");
return (scribble && strcmp(scribble, "1") == 0) ||
(pre_scribble && strcmp(pre_scribble, "1") == 0) ||
(guard_malloc && strstr(guard_malloc, "libgmalloc") != NULL);
#endif
}
static int incr_full_index_rss_limit_mb(void) {