Skip to content

Commit 36463c2

Browse files
author
Tor Didriksen
committed
Bug #32859533 -DWITH_ASAN=ON CMAKE OPTION DOES NOT ADD -FSANITIZE=ADDRESS COMPILER FLAG
There was a glitch in the patch for Bug #32287863 BACKPORT THE PATCH FOR BUG #27874068 ADD SUPPORT FOR -DCMAKE_BUILD_TYPE=RELEASE Add -fsanitize=address to C/CXX FLAGS if the feature test succeeds. Also fix a broken feature test for crypt (function and library). Change-Id: I537b0bda616da5216b613ae714e0859afed9f114
1 parent 21c3fa1 commit 36463c2

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,8 @@ MACRO(MY_SANITIZER_CHECK SAN_OPT RESULT)
344344
MY_CHECK_C_COMPILER_FLAG("${SAN_OPT}" C_RESULT)
345345
MY_CHECK_CXX_COMPILER_FLAG("${SAN_OPT}" CXX_RESULT)
346346
IF(C_RESULT AND CXX_RESULT)
347+
STRING_APPEND(CMAKE_C_FLAGS " ${SAN_OPT}")
348+
STRING_APPEND(CMAKE_CXX_FLAGS " ${SAN_OPT}")
347349
# We switch on basic optimization also for debug builds.
348350
# We disable inlining for stack trace readability.
349351
# With optimization we may get some warnings, so we switch off -Werror
@@ -360,10 +362,10 @@ MACRO(MY_SANITIZER_CHECK SAN_OPT RESULT)
360362
ENDMACRO()
361363

362364
OPTION(WITH_ASAN "Enable address sanitizer" OFF)
363-
OPTION(WITH_ASAN_SCOPE "Enable -fsanitize-address-use-after-scope" OFF)
364365
IF(WITH_ASAN)
365366
MY_SANITIZER_CHECK("-fsanitize=address" WITH_ASAN_OK)
366367
IF(WITH_ASAN_OK)
368+
OPTION(WITH_ASAN_SCOPE "Enable -fsanitize-address-use-after-scope" ON)
367369
SET(HAVE_ASAN 1)
368370
# This works with clang, but not gcc it seems.
369371
MY_CHECK_CXX_COMPILER_FLAG(

configure.cmake

+9
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,15 @@ IF(UNIX)
150150
ENDIF()
151151
MY_SEARCH_LIBS(gethostbyname_r "nsl_r;nsl" LIBNSL)
152152
MY_SEARCH_LIBS(bind "bind;socket" LIBBIND)
153+
# Feature test broken with -fsanitize=address, look for lib first.
154+
IF(CMAKE_C_FLAGS MATCHES "-fsanitize=")
155+
CHECK_LIBRARY_EXISTS(crypt crypt "" HAVE_crypt_IN_crypt)
156+
# If found, do not look in libc.
157+
IF(HAVE_crypt_IN_crypt)
158+
SET(LIBCRYPT crypt)
159+
SET(${LIBCRYPT} 1)
160+
ENDIF()
161+
ENDIF()
153162
MY_SEARCH_LIBS(crypt crypt LIBCRYPT)
154163
MY_SEARCH_LIBS(setsockopt socket LIBSOCKET)
155164
MY_SEARCH_LIBS(dlopen dl LIBDL)

mysql-test/include/have_grep.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
123
55
456
66
EOF
7-
--error 0,1,2,127,512
7+
--error 0,1,2,42,127,512
88
--exec grep -v -e "123" $MYSQL_TMP_DIR/grep_check
99
let $status= $__error;
1010
--remove_file $MYSQL_TMP_DIR/grep_check

mysql-test/suite/innodb/t/alter_crash.test

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Crash-safe InnoDB ALTER operations
22

33
--source include/not_valgrind.inc
4+
--source include/not_asan.inc
45
--source include/not_embedded.inc
56
--source include/have_innodb.inc
67
--source include/have_debug.inc

unittest/gunit/segfault-t.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ TEST_F(FatalSignalDeathTest, Segfault)
6868
gtest library instead.
6969
*/
7070
EXPECT_DEATH_IF_SUPPORTED(*pint= 42, "");
71-
#elif defined(__SANITIZE_ADDRESS__)
71+
#elif defined(HAVE_ASAN)
7272
/* gcc 4.8.1 with '-fsanitize=address -O1' */
7373
/* Newer versions of ASAN give other error message, disable it */
7474
// EXPECT_DEATH_IF_SUPPORTED(*pint= 42, ".*ASAN:SIGSEGV.*");

0 commit comments

Comments
 (0)