Commit 95201d11 authored by Andrew Gallagher's avatar Andrew Gallagher Committed by Jordan DeLong

folly: don't inline functions with ASAN disabled

Summary:
The address sanitizer disabling attribute has some issues in gcc when
the function is inlined.

Test Plan: Built and ran tao tests with ASAN.

Reviewed By: philipp@fb.com

FB internal diff: D962930
parent 6a7ee8aa
......@@ -113,21 +113,26 @@ namespace folly {
#endif
// Different versions of gcc/clang support different versions of
// the address sanitizer attribute.
// the address sanitizer attribute. Unfortunately, this attribute
// has issues when inlining is used, so disable that as well.
#if defined(__clang__)
# if __has_feature(address_sanitizer)
# if __has_attribute(__no_address_safety_analysis__)
# define FBSTRING_DISABLE_ADDRESS_SANITIZER \
__attribute__((__no_address_safety_analysis__))
__attribute__((__no_address_safety_analysis__, __noinline__))
# elif __has_attribute(__no_sanitize_address__)
# define FBSTRING_DISABLE_ADDRESS_SANITIZER \
__attribute__((__no_sanitize_address__))
# else
# define FBSTRING_DISABLE_ADDRESS_SANITIZER
__attribute__((__no_sanitize_address__, __noinline__))
# endif
# endif
#elif defined (__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)
#elif defined (__GNUC__) && \
(__GNUC__ == 4) && \
(__GNUC_MINOR__ >= 8) && \
__SANITIZE_ADDRESS__
# define FBSTRING_DISABLE_ADDRESS_SANITIZER \
__attribute__((__no_address_safety_analysis__))
#else
__attribute__((__no_address_safety_analysis__, __noinline__))
#endif
#ifndef FBSTRING_DISABLE_ADDRESS_SANITIZER
# define FBSTRING_DISABLE_ADDRESS_SANITIZER
#endif
......
......@@ -85,21 +85,26 @@ struct MaxAlign { char c; } __attribute__((aligned));
#endif
/* Define attribute wrapper for function attribute used to disable
* address sanitizer instrumentation */
* address sanitizer instrumentation. Unfortunately, this attribute
* has issues when inlining is used, so disable that as well. */
#if defined(__clang__)
# if __has_feature(address_sanitizer)
# if __has_attribute(__no_address_safety_analysis__)
# define FOLLY_DISABLE_ADDRESS_SANITIZER \
__attribute__((__no_address_safety_analysis__))
__attribute__((__no_address_safety_analysis__, __noinline__))
# elif __has_attribute(__no_sanitize_address__)
# define FOLLY_DISABLE_ADDRESS_SANITIZER \
__attribute__((__no_sanitize_address__))
# else
# define FOLLY_DISABLE_ADDRESS_SANITIZER
__attribute__((__no_sanitize_address__, __noinline__))
# endif
# endif
#elif defined (__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)
#elif defined (__GNUC__) && \
(__GNUC__ == 4) && \
(__GNUC_MINOR__ >= 8) && \
__SANITIZE_ADDRESS__
# define FOLLY_DISABLE_ADDRESS_SANITIZER \
__attribute__((__no_address_safety_analysis__))
#else
__attribute__((__no_address_safety_analysis__, __noinline__))
#endif
#ifndef FOLLY_DISABLE_ADDRESS_SANITIZER
# define FOLLY_DISABLE_ADDRESS_SANITIZER
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment