From b14e0eb90ff6e455fff07a4f988dbd0dfe8f86df Mon Sep 17 00:00:00 2001 From: Roman Kennke Date: Fri, 3 Jul 2026 14:51:20 +0200 Subject: [PATCH] fix(test): forkEvery for asan Test task to bound cumulative heap growth The ASAN test JVM is pinned to -Xmx512m to keep the heap below ASan's shadow-memory region (ASLR constraint). Without forkEvery, Gradle reuses a single JVM for the entire ddprof-test:testAsan suite, and per-test allocations (JFR recordings, JMC object models) accumulate across ~100+ test classes until the shared heap OOMs late in the run, even though every individual test passes. Restart the JVM every 25 classes to bound cumulative growth. Co-Authored-By: Claude Sonnet 5 --- .../datadoghq/profiler/ProfilerTestPlugin.kt | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/build-logic/conventions/src/main/kotlin/com/datadoghq/profiler/ProfilerTestPlugin.kt b/build-logic/conventions/src/main/kotlin/com/datadoghq/profiler/ProfilerTestPlugin.kt index 60c2ce615..f76da2c8a 100644 --- a/build-logic/conventions/src/main/kotlin/com/datadoghq/profiler/ProfilerTestPlugin.kt +++ b/build-logic/conventions/src/main/kotlin/com/datadoghq/profiler/ProfilerTestPlugin.kt @@ -313,12 +313,21 @@ class ProfilerTestPlugin : Plugin { // Sanitizer conditions when (testConfig.configName) { - "asan" -> testTask.onlyIf { - PlatformUtils.locateLibasan() != null && - // Skip J9+ASAN: OpenJ9 has known GC stack-scanning and defineClass - // race bugs exposed by ASAN timing - // https://github.com/eclipse-openj9/openj9/issues/23514 - !PlatformUtils.isTestJvmJ9() + "asan" -> { + testTask.onlyIf { + PlatformUtils.locateLibasan() != null && + // Skip J9+ASAN: OpenJ9 has known GC stack-scanning and defineClass + // race bugs exposed by ASAN timing + // https://github.com/eclipse-openj9/openj9/issues/23514 + !PlatformUtils.isTestJvmJ9() + } + // The ASAN test JVM is pinned to -Xmx512m (see ConfigurationPresets.kt) + // to keep the heap below ASan's shadow-memory region. Without forking, + // Gradle reuses one JVM for the whole suite, and per-test allocations + // (JFR recordings, JMC object models) accumulate until it OOMs late in + // the run even though every individual test passes. Restart periodically + // to bound cumulative heap growth. + testTask.setForkEvery(25) } // TSan + JVM integration tests are incompatible: the profiler's signal // handlers (SIGPROF at 1ms) are TSan-instrumented; when a signal fires