Skip to content

Commit 71a929d

Browse files
author
Tor Didriksen
committed
Bug#27660330 ADD SUPPORT FOR CLANG UBSAN basic patch
Basic patch to get clang UBSAN up and running. protoc built with clang -fsanitize=undefined dumps core, so strip away those flags in extra/protobuf/CMakeLists.txt Add clang version of SUPPRESS_UBSAN which is slightly different from the one we already have for gcc. Increase default thread stack size for UBSAN builds: reuse settings from gcc UBSAN on 32bit platforms. Change-Id: I7f6811e8c352121a2e569765c8877c0c8ddedaeb
1 parent 85fbd10 commit 71a929d

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

extra/protobuf/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
6464
ENDIF()
6565
ENDIF()
6666

67+
# protoc built with clang -fsanitize=undefined dumps core
68+
IF (HAVE_UBSAN)
69+
STRING(REPLACE "-fsanitize=undefined" ""
70+
CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
71+
STRING(REPLACE "-fsanitize=undefined" ""
72+
CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
73+
STRING(REPLACE "-fsanitize=undefined" ""
74+
CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
75+
ENDIF()
76+
6777
ADD_DEFINITIONS(-DHAVE_ZLIB)
6878
IF(CMAKE_USE_PTHREADS_INIT)
6979
ADD_DEFINITIONS(-DHAVE_PTHREAD)

include/my_compiler.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef MY_COMPILER_INCLUDED
22
#define MY_COMPILER_INCLUDED
33

4-
/* Copyright (c) 2010, 2017, Oracle and/or its affiliates. All rights reserved.
4+
/* Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
55
66
This program is free software; you can redistribute it and/or modify
77
it under the terms of the GNU General Public License, version 2.0,
@@ -171,7 +171,11 @@ struct my_aligned_storage {
171171
#endif
172172

173173
#ifndef SUPPRESS_UBSAN
174-
#if __has_attribute(no_sanitize_undefined)
174+
// clang -fsanitize=undefined
175+
#if defined(HAVE_UBSAN) && defined(__clang__)
176+
#define SUPPRESS_UBSAN MY_ATTRIBUTE((no_sanitize("undefined")))
177+
// gcc -fsanitize=undefined
178+
#elif __has_attribute(no_sanitize_undefined)
175179
#define SUPPRESS_UBSAN MY_ATTRIBUTE((no_sanitize_undefined))
176180
#else
177181
#define SUPPRESS_UBSAN

include/my_thread.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -53,7 +53,7 @@
5353
*/
5454
#if defined(__sparc) && (defined(__SUNPRO_CC) || defined(__SUNPRO_C))
5555
#define STACK_MULTIPLIER 2UL
56-
#elif defined HAVE_UBSAN && SIZEOF_CHARP == 4
56+
#elif defined HAVE_UBSAN
5757
#define STACK_MULTIPLIER 3UL
5858
#else
5959
#define STACK_MULTIPLIER 1UL

mysql-test/include/mysqld--help.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ perl;
6161
# s/\b196608\b/262144/;
6262
# s/\b524288\b/262144/;
6363
# s/\b393216\b/262144/;
64+
s/\b860160\b/262144/;
6465
s/\b573440\b/262144/;
6566
s/\b286720\b/262144/;
6667
s/\b442368\b/262144/;

0 commit comments

Comments
 (0)