From 892f0a289fd58474d0b5e996e9caa3f21dc2e635 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Tue, 20 Nov 2018 16:01:46 +0000 Subject: [PATCH] FS-11516 [build-system] Add --enable-pool-sanitizer configure flag. This will make it easier to find memory issues when using address sanitizer. Also added -fstack-protector-strong when using --enable-address-sanitizer. --- configure.ac | 14 ++++++++++++-- libs/apr/memory/unix/apr_pools.c | 18 ++++++++++-------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index 0f24452937..0d7607f403 100644 --- a/configure.ac +++ b/configure.ac @@ -1817,11 +1817,21 @@ AC_ARG_ENABLE(address_sanitizer, [enable_address_sanitizer="no"]) if test "${enable_address_sanitizer}" = "yes"; then - APR_ADDTO(CFLAGS, -fsanitize=address -fno-omit-frame-pointer) - APR_ADDTO(CXXFLAGS, -fsanitize=address -fno-omit-frame-pointer) + APR_ADDTO(CFLAGS, -fsanitize=address -fno-omit-frame-pointer -fstack-protector-strong) + APR_ADDTO(CXXFLAGS, -fsanitize=address -fno-omit-frame-pointer -fstack-protector-strong) APR_ADDTO(LDFLAGS, -fsanitize=address) fi +AC_ARG_ENABLE(, + [AC_HELP_STRING([--enable-pool-sanitizer],[build with sanitizer friendly pool behavior])], + [enable_pool_sanitizer="$enable_pool_sanitizer"], + [enable_pool_sanitizer="no"]) + +if test "${enable_pool_sanitizer}" = "yes"; then + APR_ADDTO(CFLAGS, -DDESTROY_POOLS) + ac_configure_args="$ac_configure_args --enable-pool-debug=yes" +fi + # we never use this, and hard setting it will make cross compile work better ac_cv_file_dbd_apr_dbd_mysql_c=no diff --git a/libs/apr/memory/unix/apr_pools.c b/libs/apr/memory/unix/apr_pools.c index 7ddc5e2af8..600b0772cc 100644 --- a/libs/apr/memory/unix/apr_pools.c +++ b/libs/apr/memory/unix/apr_pools.c @@ -507,6 +507,16 @@ static void free_proc_chain(struct process_chain *procs); static void pool_destroy_debug(apr_pool_t *pool, const char *file_line); #endif + +#if APR_HAS_THREADS +APR_DECLARE(void) apr_pool_mutex_set(apr_pool_t *pool, + apr_thread_mutex_t *mutex) +{ + pool->user_mutex = mutex; +} +#endif + + #if !APR_POOL_DEBUG /* * Initialization @@ -729,14 +739,6 @@ APR_DECLARE(void) apr_pool_clear(apr_pool_t *pool) #endif } -#if APR_HAS_THREADS -APR_DECLARE(void) apr_pool_mutex_set(apr_pool_t *pool, - apr_thread_mutex_t *mutex) -{ - pool->user_mutex = mutex; -} -#endif - APR_DECLARE(void) apr_pool_destroy(apr_pool_t *pool) { apr_memnode_t *active;