MDEV-16660: Increase the DEFAULT_THREAD_STACK for ASAN

To allow cmake -DWITH_ASAN=ON to work out of the box when using
newer compilers, we must increase the default thread stack size.

By design, AddressSanitizer will allocate some "sentinel" areas in
stack frames so that it can better catch buffer overflows, by trapping
access to memory addresses that reside between stack-allocated variables.

Apparently, some parameters related to this have been changed
recently, possibly to allow -fsanitize=address to catch more errors.
This commit is contained in:
Marko Mäkelä 2023-11-17 14:12:48 +02:00
parent 0381197855
commit f5fdb9cec5

View file

@ -704,11 +704,19 @@ extern void my_mutex_end(void);
We need to have at least 256K stack to handle calls to myisamchk_init()
with the current number of keys and key parts.
*/
#if defined(__SANITIZE_ADDRESS__) || defined(WITH_UBSAN)
#define DEFAULT_THREAD_STACK (383*1024L) /* 392192 */
#else
#define DEFAULT_THREAD_STACK (292*1024L) /* 299008 */
#endif
# if defined(__SANITIZE_ADDRESS__) || defined(WITH_UBSAN)
/*
Optimized WITH_ASAN=ON executables produced
by GCC 12.3.0, GCC 13.2.0, or clang 16.0.6
would fail ./mtr main.1st when the stack size is 5 MiB.
The minimum is more than 6 MiB for CMAKE_BUILD_TYPE=RelWithDebInfo and
more than 8 MiB for CMAKE_BUILD_TYPE=Debug.
Let us add some safety margin.
*/
# define DEFAULT_THREAD_STACK (10L<<20)
# else
# define DEFAULT_THREAD_STACK (292*1024L) /* 299008 */
# endif
#endif
#define MY_PTHREAD_LOCK_READ 0