@@ -197,9 +197,8 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_JDK_OPTIONS],
197
197
# three different page sizes: 4K, 64K, and if run on Mac m1 hardware, 16K.
198
198
COMPATIBLE_CDS_ALIGNMENT_DEFAULT=false
199
199
if test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xaarch64"; then
200
- COMPATIBLE_CDS_ALIGNMENT_DEFAULT=true
200
+ COMPATIBLE_CDS_ALIGNMENT_DEFAULT=auto
201
201
fi
202
- AC_SUBST ( COMPATIBLE_CDS_ALIGNMENT_DEFAULT )
203
202
204
203
# Compress jars
205
204
COMPRESS_JARS=false
@@ -438,12 +437,23 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER],
438
437
# It's harmless to be suppressed in clang as well.
439
438
ASAN_CFLAGS="-fsanitize=address -Wno-stringop-truncation -fno-omit-frame-pointer -fno-common -DADDRESS_SANITIZER"
440
439
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
441
449
elif test "x$TOOLCHAIN_TYPE" = "xmicrosoft"; then
442
450
# -Oy- is equivalent to -fno-omit-frame-pointer in GCC/Clang.
443
451
ASAN_CFLAGS="-fsanitize=address -Oy- -DADDRESS_SANITIZER"
444
452
# MSVC produces a warning if you pass -fsanitize=address to the linker. It also complains
445
453
$ if -DEBUG is not passed to the linker when building with ASan.
446
454
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'
447
457
fi
448
458
JVM_CFLAGS="$JVM_CFLAGS $ASAN_CFLAGS"
449
459
JVM_LDFLAGS="$JVM_LDFLAGS $ASAN_LDFLAGS"
@@ -496,9 +506,15 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_LEAK_SANITIZER],
496
506
#
497
507
AC_DEFUN_ONCE ( [ JDKOPT_SETUP_UNDEFINED_BEHAVIOR_SANITIZER] ,
498
508
[
509
+ UTIL_ARG_WITH(NAME: additional-ubsan-checks, TYPE: string,
510
+ DEFAULT: [ ] ,
511
+ DESC: [ Customizes the ubsan checks] ,
512
+ OPTIONAL: true)
513
+
499
514
# GCC reports lots of likely false positives for stringop-truncation and format-overflow.
500
515
# Silence them for now.
501
- UBSAN_CHECKS="-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base -fno-sanitize=alignment"
516
+ UBSAN_CHECKS="-fsanitize=undefined -fsanitize=float-divide-by-zero -fno-sanitize=shift-base -fno-sanitize=alignment \
517
+ $ADDITIONAL_UBSAN_CHECKS"
502
518
UBSAN_CFLAGS="$UBSAN_CHECKS -Wno-stringop-truncation -Wno-format-overflow -fno-omit-frame-pointer -DUNDEFINED_BEHAVIOR_SANITIZER"
503
519
UBSAN_LDFLAGS="$UBSAN_CHECKS"
504
520
UTIL_ARG_ENABLE(NAME: ubsan, DEFAULT: false, RESULT: UBSAN_ENABLED,
@@ -666,7 +682,7 @@ AC_DEFUN([JDKOPT_ENABLE_DISABLE_COMPATIBLE_CDS_ALIGNMENT],
666
682
UTIL_ARG_ENABLE(NAME: compatible-cds-alignment, DEFAULT: $COMPATIBLE_CDS_ALIGNMENT_DEFAULT,
667
683
RESULT: ENABLE_COMPATIBLE_CDS_ALIGNMENT,
668
684
DESC: [ enable use alternative compatible cds core region alignment] ,
669
- DEFAULT_DESC: [ disabled] ,
685
+ DEFAULT_DESC: [ disabled except on linux-aarch64 ] ,
670
686
CHECKING_MSG: [ if compatible cds region alignment enabled] ,
671
687
CHECK_AVAILABLE: [
672
688
AC_MSG_CHECKING ( [ if CDS archive is available] )
0 commit comments