@@ -51,7 +51,7 @@ object ConfigurationPresets {
5151 configureTsan(this , currentPlatform, currentArch, version, rootDir, compiler)
5252 }
5353 register(" fuzzer" ) {
54- configureFuzzer(this , currentPlatform, currentArch, version, rootDir)
54+ configureFuzzer(this , currentPlatform, currentArch, version, rootDir, compiler )
5555 }
5656 }
5757
@@ -222,9 +222,13 @@ object ConfigurationPresets {
222222 // HeapBaseMinAddress is not accepted by JDK <= 11 (constraint violation);
223223 // those JDKs rely on the vm.mmap_rnd_bits=8 CI-level mitigation instead.
224224 if (PlatformUtils .testJvmMajorVersion() >= 12 ) {
225+ // HeapBaseMinAddress=64MB leaves ~1.9GB of address space below the
226+ // shadow region (0x7fff7000); 1024m keeps heap+CompressedClassSpace
227+ // well within that margin while giving forkEvery-restarted JVMs
228+ // enough headroom to avoid "Java heap space" OOMs seen in nightly CI.
225229 config.testJvmArgs.addAll(listOf (
226230 " -XX:HeapBaseMinAddress=0x4000000" ,
227- " -Xmx512m " ,
231+ " -Xmx1024m " ,
228232 " -XX:CompressedClassSpaceSize=256m"
229233 ))
230234 }
@@ -309,7 +313,8 @@ object ConfigurationPresets {
309313 platform : Platform ,
310314 architecture : Architecture ,
311315 version : String ,
312- rootDir : File
316+ rootDir : File ,
317+ compiler : String = "gcc"
313318 ) {
314319 config.platform.set(platform)
315320 config.architecture.set(architecture)
@@ -335,7 +340,28 @@ object ConfigurationPresets {
335340 when (platform) {
336341 Platform .LINUX -> {
337342 config.compilerArgs.set(fuzzerCompilerArgs + commonLinuxCompilerArgs(version))
338- config.linkerArgs.set(commonLinuxLinkerArgs() + fuzzerLinkerArgs)
343+
344+ // commonLinuxLinkerArgs() carries -Wl,-z,defs, which forbids the
345+ // undefined __asan_*/__ubsan_* symbols the instrumented objects
346+ // reference. -fsanitize=address only links the runtime into
347+ // executables, not shared libraries, so the fuzzer .so needs the
348+ // runtime linked explicitly — same treatment (and rationale) as the
349+ // asan config. On clang this resolves both __asan_* and __ubsan_*
350+ // from one clang_rt.asan runtime; on gcc it adds -lubsan.
351+ val libasan = PlatformUtils .locateLibasan(compiler)
352+ val fuzzerRuntimeArgs = if (libasan != null ) {
353+ val asanLibDir = File (libasan).parent
354+ val asanLibName = File (libasan).nameWithoutExtension.removePrefix(" lib" )
355+ val ubsanLibs = if (asanLibName.startsWith(" clang_rt" )) emptyList()
356+ else listOf (" -lubsan" )
357+ listOf (" -L$asanLibDir " , " -l$asanLibName " ,
358+ " -Wl,-rpath,$asanLibDir " ) +
359+ ubsanLibs +
360+ fuzzerLinkerArgs
361+ } else {
362+ fuzzerLinkerArgs
363+ }
364+ config.linkerArgs.set(commonLinuxLinkerArgs() + fuzzerRuntimeArgs)
339365
340366 config.testEnvironment.apply {
341367 put(" ASAN_OPTIONS" , " allocator_may_return_null=1:detect_stack_use_after_return=0:handle_segv=0:abort_on_error=1:symbolize=1:suppressions=$rootDir /gradle/sanitizers/asan.supp" )
0 commit comments