File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -437,12 +437,23 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER],
437437 # It's harmless to be suppressed in clang as well.
438438 ASAN_CFLAGS="-fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER"
439439 ASAN_LDFLAGS="-fsanitize=address"
440+ # detect_stack_use_after_return causes ASAN to offload stack-local
441+ # variables to c-heap and therefore breaks assumptions in hotspot
442+ # that rely on data (e.g. Marks) living in thread stacks.
443+ if test "x$TOOLCHAIN_TYPE" = "xgcc"; then
444+ ASAN_CFLAGS="$ASAN_CFLAGS --param asan-use-after-return=0"
445+ fi
446+ if test "x$TOOLCHAIN_TYPE" = "xclang"; then
447+ ASAN_CFLAGS="$ASAN_CFLAGS -fsanitize-address-use-after-return=never"
448+ fi
440449 elif test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
441450 # -Oy- is equivalent to -fno-omit-frame-pointer in GCC/Clang.
442451 ASAN_CFLAGS="-fsanitize=address -Oy- -DADDRESS_SANITIZER"
443452 # MSVC produces a warning if you pass -fsanitize=address to the linker. It also complains
444453 $ if -DEBUG is not passed to the linker when building with ASan.
445454 ASAN_LDFLAGS="-debug"
455+ # -fsanitize-address-use-after-return is off by default in MS Visual Studio 22 (19.37.32824).
456+ # cl : Command line warning D9002 : ignoring unknown option '-fno-sanitize-address-use-after-return'
446457 fi
447458 JVM_CFLAGS="$JVM_CFLAGS $ASAN_CFLAGS"
448459 JVM_LDFLAGS="$JVM_LDFLAGS $ASAN_LDFLAGS"
You can’t perform that action at this time.
0 commit comments