* [tarantool-patches] [PATCH] Fix build with ENABLE_ASAN=ON @ 2018-12-20 12:49 Alexander Turenko 2018-12-20 13:19 ` Vladimir Davydov 2018-12-21 7:37 ` [tarantool-patches] " Kirill Yukhin 0 siblings, 2 replies; 4+ messages in thread From: Alexander Turenko @ 2018-12-20 12:49 UTC (permalink / raw) To: Kirill Yukhin; +Cc: Alexander Turenko, tarantool-patches It still supports only clang, so use CC=clang CXX=clang++ cmake -DENABLE_ASAN on systems where gcc is default compiler. Fixes #3070. --- https://github.com/tarantool/tarantool/issues/3070 https://github.com/tarantool/tarantool/tree/Totktonada/gh-3070-fix-asan src/fiber.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fiber.c b/src/fiber.c index 7658a2294..743ceff7a 100644 --- a/src/fiber.c +++ b/src/fiber.c @@ -54,7 +54,7 @@ static int (*fiber_invoke)(fiber_func f, va_list ap); __sanitizer_start_switch_fiber((will_switch_back) ? &var_name : NULL, \ (bottom), (size)) #define ASAN_FINISH_SWITCH_FIBER(var_name) \ - __sanitizer_finish_switch_fiber(var_name); + __sanitizer_finish_switch_fiber(var_name, 0, 0); #else #define ASAN_START_SWITCH_FIBER(var_name, will_switch_back, bottom, size) -- 2.20.0 ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [tarantool-patches] [PATCH] Fix build with ENABLE_ASAN=ON 2018-12-20 12:49 [tarantool-patches] [PATCH] Fix build with ENABLE_ASAN=ON Alexander Turenko @ 2018-12-20 13:19 ` Vladimir Davydov 2018-12-20 18:24 ` Alexander Turenko 2018-12-21 7:37 ` [tarantool-patches] " Kirill Yukhin 1 sibling, 1 reply; 4+ messages in thread From: Vladimir Davydov @ 2018-12-20 13:19 UTC (permalink / raw) To: Alexander Turenko; +Cc: Kirill Yukhin, tarantool-patches On Thu, Dec 20, 2018 at 03:49:48PM +0300, Alexander Turenko wrote: > It still supports only clang, so use CC=clang CXX=clang++ cmake > -DENABLE_ASAN on systems where gcc is default compiler. > > Fixes #3070. > --- > > https://github.com/tarantool/tarantool/issues/3070 > https://github.com/tarantool/tarantool/tree/Totktonada/gh-3070-fix-asan > > src/fiber.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/fiber.c b/src/fiber.c > index 7658a2294..743ceff7a 100644 > --- a/src/fiber.c > +++ b/src/fiber.c > @@ -54,7 +54,7 @@ static int (*fiber_invoke)(fiber_func f, va_list ap); > __sanitizer_start_switch_fiber((will_switch_back) ? &var_name : NULL, \ > (bottom), (size)) > #define ASAN_FINISH_SWITCH_FIBER(var_name) \ > - __sanitizer_finish_switch_fiber(var_name); > + __sanitizer_finish_switch_fiber(var_name, 0, 0); This won't work on my laptop, which has clang-3.9. Can we support all clang versions? ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [tarantool-patches] [PATCH] Fix build with ENABLE_ASAN=ON 2018-12-20 13:19 ` Vladimir Davydov @ 2018-12-20 18:24 ` Alexander Turenko 0 siblings, 0 replies; 4+ messages in thread From: Alexander Turenko @ 2018-12-20 18:24 UTC (permalink / raw) To: Vladimir Davydov; +Cc: Kirill Yukhin, tarantool-patches On Thu, Dec 20, 2018 at 04:19:45PM +0300, Vladimir Davydov wrote: > On Thu, Dec 20, 2018 at 03:49:48PM +0300, Alexander Turenko wrote: > > It still supports only clang, so use CC=clang CXX=clang++ cmake > > -DENABLE_ASAN on systems where gcc is default compiler. > > > > Fixes #3070. > > --- > > > > https://github.com/tarantool/tarantool/issues/3070 > > https://github.com/tarantool/tarantool/tree/Totktonada/gh-3070-fix-asan > > > > src/fiber.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/src/fiber.c b/src/fiber.c > > index 7658a2294..743ceff7a 100644 > > --- a/src/fiber.c > > +++ b/src/fiber.c > > @@ -54,7 +54,7 @@ static int (*fiber_invoke)(fiber_func f, va_list ap); > > __sanitizer_start_switch_fiber((will_switch_back) ? &var_name : NULL, \ > > (bottom), (size)) > > #define ASAN_FINISH_SWITCH_FIBER(var_name) \ > > - __sanitizer_finish_switch_fiber(var_name); > > + __sanitizer_finish_switch_fiber(var_name, 0, 0); > > This won't work on my laptop, which has clang-3.9. Can we support all > clang versions? Sorry, I did assumption that the release from 2016-09-02 (>2 years old) is not more actual, but it seems it does. I fixed the patch and attached the new version below. I tested it on my laptop with clang-7.0.0. Can you please test whether it works as expected for you? branch: Totktonada/gh-3070-fix-asan commit c3f3af2dc2c67392c8f256e43cd50aa539ecd5b7 Author: Alexander Turenko <alexander.turenko@tarantool.org> Date: Thu Dec 20 15:43:28 2018 +0300 Fix build with -DENABLE_ASAN=ON on >=clang-3.9.1 LLVM changes the API in the compiler-rt commit [1]. According to the date of the commit it is between clang-3.9.0 and clang-3.9.1. [1]: https://github.com/llvm-mirror/compiler-rt/commit/0b95585616bd28fc0b738289bcc5f7887d7c304e Fixes #3070. diff --git a/cmake/profile.cmake b/cmake/profile.cmake index 278399155..02d622187 100644 --- a/cmake/profile.cmake +++ b/cmake/profile.cmake @@ -43,4 +43,27 @@ endif() option(ENABLE_ASAN "Enable AddressSanitizer, a fast memory error detector based on compiler instrumentation" OFF) if (ENABLE_ASAN) add_compile_flags("C;CXX" -fsanitize=address) + + set(CMAKE_REQUIRED_FLAGS "-fsanitize=address") + check_c_source_compiles("int main(void) { + #include <sanitizer/asan_interface.h> + void *x; + __sanitizer_finish_switch_fiber(x); + return 0; + }" ASAN_INTERFACE_OLD) + check_c_source_compiles("int main(void) { + #include <sanitizer/asan_interface.h> + void *x; + __sanitizer_finish_switch_fiber(x, 0, 0); + return 0; + }" ASAN_INTERFACE_NEW) + set(CMAKE_REQUIRED_FLAGS "") + + if (ASAN_INTERFACE_OLD) + add_definitions(-DASAN_INTERFACE_OLD=1) + elseif (ASAN_INTERFACE_NEW) + add_definitions(-UASAN_INTERFACE_OLD) + else() + message(FATAL_ERROR "Cannot enable AddressSanitizer") + endif() endif() diff --git a/src/fiber.c b/src/fiber.c index 7658a2294..6f3d0ab78 100644 --- a/src/fiber.c +++ b/src/fiber.c @@ -53,8 +53,13 @@ static int (*fiber_invoke)(fiber_func f, va_list ap); void *var_name = NULL; \ __sanitizer_start_switch_fiber((will_switch_back) ? &var_name : NULL, \ (bottom), (size)) +#if ASAN_INTERFACE_OLD #define ASAN_FINISH_SWITCH_FIBER(var_name) \ __sanitizer_finish_switch_fiber(var_name); +#else +#define ASAN_FINISH_SWITCH_FIBER(var_name) \ + __sanitizer_finish_switch_fiber(var_name, 0, 0); +#endif #else #define ASAN_START_SWITCH_FIBER(var_name, will_switch_back, bottom, size) ^ permalink raw reply [flat|nested] 4+ messages in thread
* [tarantool-patches] Re: [PATCH] Fix build with ENABLE_ASAN=ON 2018-12-20 12:49 [tarantool-patches] [PATCH] Fix build with ENABLE_ASAN=ON Alexander Turenko 2018-12-20 13:19 ` Vladimir Davydov @ 2018-12-21 7:37 ` Kirill Yukhin 1 sibling, 0 replies; 4+ messages in thread From: Kirill Yukhin @ 2018-12-21 7:37 UTC (permalink / raw) To: Alexander Turenko; +Cc: tarantool-patches Hello, On 20 Dec 15:49, Alexander Turenko wrote: > It still supports only clang, so use CC=clang CXX=clang++ cmake > -DENABLE_ASAN on systems where gcc is default compiler. > > Fixes #3070. > --- > > https://github.com/tarantool/tarantool/issues/3070 > https://github.com/tarantool/tarantool/tree/Totktonada/gh-3070-fix-asan I've checked that updated patch works for 3.9+ clang and checked it into 1.10 and 2.1 branches. It should be mentioned, that ASan still won't work on 2.1 since lemon parser looks leaking to it. -- Regards, Kirill Yukhin ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-12-21 7:37 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-12-20 12:49 [tarantool-patches] [PATCH] Fix build with ENABLE_ASAN=ON Alexander Turenko 2018-12-20 13:19 ` Vladimir Davydov 2018-12-20 18:24 ` Alexander Turenko 2018-12-21 7:37 ` [tarantool-patches] " Kirill Yukhin
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox