Skip to content

Commit

Permalink
Disable address sanitizer for uthread tests
Browse files Browse the repository at this point in the history
Currently the sanitizer can't handle user thread properly.
See google/sanitizers#189 for details.
Close it temporarily to make CI sound.
  • Loading branch information
ChuanqiXu9 committed Oct 31, 2022
1 parent c68d810 commit 811ee6a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
14 changes: 10 additions & 4 deletions async_simple/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
file(GLOB coro_src "coro/*.cpp")
file(GLOB executors_src "executors/*.cpp")

if(UTHREAD)
if(${UTHREAD})
file(GLOB uthread_src "uthread/internal/*.cc")
# Compiler-rt15 enables new sanitizer option sanitize-address-use-after-return,
# But it can't take user thread well. So disable it for thread.cc as a workaround.
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "13")
set_property(SOURCE ${uthread_src} PROPERTY COMPILE_FLAGS -fsanitize-address-use-after-return=never)
# The address sanitizer may produce false-positive results for swap-context.
# See https://github.com/google/sanitizers/issues/189 for details.
# FIXME: A proper fix may add a __asan_enter_fiber and __asan_exit_fiber
# for the user thread.
# FIXME2: the new added sanitize action: address-use-after-return
# can't handle stackful coroutine well too. So disable it as a workaround now.
set_property(SOURCE ${uthread_src} PROPERTY COMPILE_OPTIONS "-fno-sanitize=address;-fsanitize-address-use-after-return=never")
#endif()
endif()

if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64")
file(GLOB uthread_asm_src "uthread/internal/aarch64/*arm64_aapcs_elf*")
elseif ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
Expand Down
10 changes: 7 additions & 3 deletions async_simple/uthread/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
file(GLOB uthread_test_src "*.cpp")

# Compiler-rt15 enables new sanitizer option sanitize-address-use-after-return,
# But it can't take user thread well. So disable it for thread.cc as a workaround.
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "13")
set_property(SOURCE ${uthread_test_src} PROPERTY COMPILE_FLAGS -fsanitize-address-use-after-return=never)
# The address sanitizer may produce false-positive results for swap-context.
# See https://github.com/google/sanitizers/issues/189 for details.
# FIXME: A proper fix may add a __asan_enter_fiber and __asan_exit_fiber
# for the user thread.
# FIXME2: the new added sanitize action: address-use-after-return
# can't handle stackful coroutine well too. So disable it as a workaround now.
set_property(SOURCE ${uthread_test_src} PROPERTY COMPILE_OPTIONS "-fno-sanitize=address;-fsanitize-address-use-after-return=never")
endif()

add_executable(async_simple_uthread_test ${uthread_test_src} ${PROJECT_SOURCE_DIR}/async_simple/test/dotest.cpp)
Expand Down

0 comments on commit 811ee6a

Please sign in to comment.