Commit c6819f96 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

fix FOLLY_SAFE_CHECK under gcc+asan

Summary:
The build was failing at link time with the claim that `__PRETTY_FUNCTION__` was in a discarded section. This occurs only under some versions of gcc with asan enabled.

This approach works by making a copy of `__PRETTY_FUNCTION__` without ever taking a reference to it.

This may not be the ideal fix, but it is the first one that worked upon experimentation.

Differential Revision: D27786615

fbshipit-source-id: 2845c85bdc8158d4b2da7cd200ce55f982285a21
parent e663b2bc
......@@ -24,21 +24,21 @@
#include <folly/Preprocessor.h>
#include <folly/lang/CArray.h>
#define FOLLY_DETAIL_SAFE_CHECK_IMPL(d, p, expr, expr_s, ...) \
if ((!d || ::folly::kIsDebug || ::folly::kIsSanitize) && \
!static_cast<bool>(expr)) { \
static constexpr ::folly::detail::safe_assert_arg \
__folly_detail_safe_assert_arg{ \
FOLLY_PP_STRINGIZE(expr_s), \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__, \
::folly::detail::safe_assert_msg_types<decltype( \
::folly::detail::safe_assert_msg_types_seq_of( \
__VA_ARGS__))>::value.data}; \
::folly::detail::safe_assert_terminate<p>( \
__folly_detail_safe_assert_arg, __VA_ARGS__); \
} \
#define FOLLY_DETAIL_SAFE_CHECK_IMPL(d, p, expr, expr_s, ...) \
if ((!d || ::folly::kIsDebug || ::folly::kIsSanitize) && \
!static_cast<bool>(expr)) { \
constexpr auto __folly_detail_safe_assert_fun = __PRETTY_FUNCTION__; \
constexpr ::folly::detail::safe_assert_arg __folly_detail_safe_assert_arg{ \
FOLLY_PP_STRINGIZE(expr_s), \
__FILE__, \
__LINE__, \
__folly_detail_safe_assert_fun, \
::folly::detail::safe_assert_msg_types<decltype( \
::folly::detail::safe_assert_msg_types_seq_of( \
__VA_ARGS__))>::value.data}; \
::folly::detail::safe_assert_terminate<p>( \
__folly_detail_safe_assert_arg, __VA_ARGS__); \
} \
[] {}()
// FOLLY_SAFE_CHECK
......
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