summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorƁukasz Langa <lukasz@langa.pl>2021-09-03 07:32:19 (GMT)
committerGitHub <noreply@github.com>2021-09-03 07:32:19 (GMT)
commitbe9de8721d63b9d8e032d508069daf88c06542c6 (patch)
treed253f5fac76d6c7a61c775048235f8836ad496d8 /configure.ac
parentb4b6342848ec0459182a992151099252434cc619 (diff)
downloadcpython-be9de8721d63b9d8e032d508069daf88c06542c6.zip
cpython-be9de8721d63b9d8e032d508069daf88c06542c6.tar.gz
cpython-be9de8721d63b9d8e032d508069daf88c06542c6.tar.bz2
bpo-34602: Quadruple stack size on macOS when compiling with UBSAN (GH-27309)
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac93
1 files changed, 53 insertions, 40 deletions
diff --git a/configure.ac b/configure.ac
index aaff79f..e01e0c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2595,6 +2595,47 @@ case $ac_sys_system/$ac_sys_release in
;;
esac
+AC_MSG_CHECKING(for --with-address-sanitizer)
+AC_ARG_WITH(address_sanitizer,
+ AS_HELP_STRING([--with-address-sanitizer],
+ [enable AddressSanitizer memory error detector, 'asan' (default is no)]),
+[
+AC_MSG_RESULT($withval)
+BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS"
+LDFLAGS="-fsanitize=address $LDFLAGS"
+# ASan works by controlling memory allocation, our own malloc interferes.
+with_pymalloc="no"
+],
+[AC_MSG_RESULT(no)])
+
+AC_MSG_CHECKING(for --with-memory-sanitizer)
+AC_ARG_WITH(memory_sanitizer,
+ AS_HELP_STRING([--with-memory-sanitizer],
+ [enable MemorySanitizer allocation error detector, 'msan' (default is no)]),
+[
+AC_MSG_RESULT($withval)
+BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
+LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"
+# MSan works by controlling memory allocation, our own malloc interferes.
+with_pymalloc="no"
+],
+[AC_MSG_RESULT(no)])
+
+AC_MSG_CHECKING(for --with-undefined-behavior-sanitizer)
+AC_ARG_WITH(undefined_behavior_sanitizer,
+ AS_HELP_STRING([--with-undefined-behavior-sanitizer],
+ [enable UndefinedBehaviorSanitizer undefined behaviour detector, 'ubsan' (default is no)]),
+[
+AC_MSG_RESULT($withval)
+BASECFLAGS="-fsanitize=undefined $BASECFLAGS"
+LDFLAGS="-fsanitize=undefined $LDFLAGS"
+with_ubsan="yes"
+],
+[
+AC_MSG_RESULT(no)
+with_ubsan="no"
+])
+
# Set info about shared libraries.
AC_SUBST(SHLIB_SUFFIX)
AC_SUBST(LDSHARED)
@@ -2798,9 +2839,18 @@ then
# Issue #18075: the default maximum stack size (8MBytes) is too
# small for the default recursion limit. Increase the stack size
# to ensure that tests don't crash
- # Note: This matches the value of THREAD_STACK_SIZE in
- # thread_pthread.h
- LINKFORSHARED="-Wl,-stack_size,1000000 $LINKFORSHARED"
+ stack_size="1000000" # 16 MB
+ if test "$with_ubsan" == "yes"
+ then
+ # Undefined behavior sanitizer requires an even deeper stack
+ stack_size="4000000" # 64 MB
+ fi
+
+ LINKFORSHARED="-Wl,-stack_size,$stack_size $LINKFORSHARED"
+
+ AC_DEFINE_UNQUOTED(THREAD_STACK_SIZE,
+ 0x$stack_size,
+ [Custom thread stack size depending on chosen sanitizer runtimes.])
if test "$enable_framework"
then
@@ -3044,43 +3094,6 @@ esac
AC_MSG_RESULT("$TZPATH")])
AC_SUBST(TZPATH)
-AC_MSG_CHECKING(for --with-address-sanitizer)
-AC_ARG_WITH(address_sanitizer,
- AS_HELP_STRING([--with-address-sanitizer],
- [enable AddressSanitizer memory error detector, 'asan' (default is no)]),
-[
-AC_MSG_RESULT($withval)
-BASECFLAGS="-fsanitize=address -fno-omit-frame-pointer $BASECFLAGS"
-LDFLAGS="-fsanitize=address $LDFLAGS"
-# ASan works by controlling memory allocation, our own malloc interferes.
-with_pymalloc="no"
-],
-[AC_MSG_RESULT(no)])
-
-AC_MSG_CHECKING(for --with-memory-sanitizer)
-AC_ARG_WITH(memory_sanitizer,
- AS_HELP_STRING([--with-memory-sanitizer],
- [enable MemorySanitizer allocation error detector, 'msan' (default is no)]),
-[
-AC_MSG_RESULT($withval)
-BASECFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer $BASECFLAGS"
-LDFLAGS="-fsanitize=memory -fsanitize-memory-track-origins=2 $LDFLAGS"
-# MSan works by controlling memory allocation, our own malloc interferes.
-with_pymalloc="no"
-],
-[AC_MSG_RESULT(no)])
-
-AC_MSG_CHECKING(for --with-undefined-behavior-sanitizer)
-AC_ARG_WITH(undefined_behavior_sanitizer,
- AS_HELP_STRING([--with-undefined-behavior-sanitizer],
- [enable UndefinedBehaviorSanitizer undefined behaviour detector, 'ubsan' (default is no)]),
-[
-AC_MSG_RESULT($withval)
-BASECFLAGS="-fsanitize=undefined $BASECFLAGS"
-LDFLAGS="-fsanitize=undefined $LDFLAGS"
-],
-[AC_MSG_RESULT(no)])
-
# Most SVR4 platforms (e.g. Solaris) need -lsocket and -lnsl.
AC_CHECK_LIB(nsl, t_open, [LIBS="-lnsl $LIBS"]) # SVR4
AC_CHECK_LIB(socket, socket, [LIBS="-lsocket $LIBS"], [], $LIBS) # SVR4 sockets