Skip to content

Commit b4df380

Browse files
Jan KratochvilKim Barrett
Jan Kratochvil
authored and
Kim Barrett
committed
8334763: --enable-asan: assert(_thread->is_in_live_stack((address)this)) failed: not on stack?
Reviewed-by: kbarrett, stuefe, erikj
1 parent cd46c87 commit b4df380

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

make/autoconf/jdk-options.m4

+11
Original file line numberDiff line numberDiff 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"

0 commit comments

Comments
 (0)