Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1502 break unit tests on Address (asan) #1503

Merged
merged 8 commits into from
Sep 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ci/azure/azure-gcc-8-ubuntu-mpich.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ variables:
TS_YEAR: 0
TS_MONTH: 0
TS_DAY: 0
LSAN_OPTIONS: suppressions=/vt/tests/knowns_leaks.supp
LSAN_OPTIONS: suppressions=/vt/tests/lsan.supp

stages:
- stage: Build
Expand Down
1 change: 1 addition & 0 deletions ci/docker/ubuntu-20.04-clang-cpp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ RUN apt-get update -y -q && \
make-guile \
libomp5 \
libomp-dev \
llvm-10 \
Copy link
Contributor Author

@jstrzebonski jstrzebonski Sep 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In llvm-10 package there is a llvm-symbolizer. Thanks to it produced traces are human-readable, for example:

879: [ RUN      ] TestSanitizers.test_if_asan_fails
879: =================================================================
879: ==24915==ERROR: AddressSanitizer: heap-use-after-free on address 0x619000004680 at pc 0x0000012ba187 bp 0x7ffcd5045d20 sp 0x7ffcd50454b8
879: WRITE of size 11 at 0x619000004680 thread T0
879:     #0 0x12ba186 in vsprintf (/build/vt/tests/utils_nompi+0x12ba186)
879:     #1 0x12bb113 in sprintf (/build/vt/tests/utils_nompi+0x12bb113)
879:     #2 0x136226a in vt::tests::unit::test_if_asan_fails() /vt/tests/unit/utils/test_safe_union.nompi.cc:301:3
879:     #3 0x13626e8 in vt::tests::unit::TestSanitizers_test_if_asan_fails_Test::TestBody()::GTestExpectFatalFailureHelper::Execute() /vt/tests/unit/utils/test_safe_union.nompi.cc:307:3
879:     #4 0x13624fe in vt::tests::unit::TestSanitizers_test_if_asan_fails_Test::TestBody() /vt/tests/unit/utils/test_safe_union.nompi.cc:307:3
879:     #5 0x146946a in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /vt/tests/extern/googletest/googletest/src/gtest.cc:2433:10
879:     #6 0x142d737 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /vt/tests/extern/googletest/googletest/src/gtest.cc:2469:14
879:     #7 0x13e4d49 in testing::Test::Run() /vt/tests/extern/googletest/googletest/src/gtest.cc:2508:5
879:     #8 0x13e6e59 in testing::TestInfo::Run() /vt/tests/extern/googletest/googletest/src/gtest.cc:2684:11
879:     #9 0x13e8124 in testing::TestSuite::Run() /vt/tests/extern/googletest/googletest/src/gtest.cc:2816:28
879:     #10 0x1404565 in testing::internal::UnitTestImpl::RunAllTests() /vt/tests/extern/googletest/googletest/src/gtest.cc:5338:44
879:     #11 0x1471a2a in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /vt/tests/extern/googletest/googletest/src/gtest.cc:2433:10
879:     #12 0x14343f2 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /vt/tests/extern/googletest/googletest/src/gtest.cc:2469:14
879:     #13 0x1403880 in testing::UnitTest::Run() /vt/tests/extern/googletest/googletest/src/gtest.cc:4925:10
879:     #14 0x136b010 in RUN_ALL_TESTS() /vt/tests/extern/googletest/googletest/include/gtest/gtest.h:2473:46
879:     #15 0x1345987 in main /vt/tests/unit/main.cc:66:10
879:     #16 0x7fe2f733b0b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
879:     #17 0x129b19d in _start (/build/vt/tests/utils_nompi+0x129b19d)
879: 
879: 0x619000004680 is located 0 bytes inside of 1024-byte region [0x619000004680,0x619000004a80)
879: freed by thread T0 here:
879: ==24915==AddressSanitizer CHECK failed: /build/llvm-toolchain-10-yegZYJ/llvm-toolchain-10-10.0.0/compiler-rt/lib/asan/asan_descriptions.cpp:177 "((res.trace)) != (0)" (0x0, 0x0)
879:     #0 0x131ba8e in __asan::AsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/build/vt/tests/utils_nompi+0x131ba8e)
879:     #1 0x132ffaf in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/build/vt/tests/utils_nompi+0x132ffaf)
879:     #2 0x12a412b in __asan::HeapAddressDescription::Print() const (/build/vt/tests/utils_nompi+0x12a412b)
879:     #3 0x12a6f75 in __asan::ErrorGeneric::Print() (/build/vt/tests/utils_nompi+0x12a6f75)
879:     #4 0x13176f8 in __asan::ScopedInErrorReport::~ScopedInErrorReport() (/build/vt/tests/utils_nompi+0x13176f8)
879:     #5 0x131932d in __asan::ReportGenericError(unsigned long, unsigned long, unsigned long, unsigned long, bool, unsigned long, unsigned int, bool) (/build/vt/tests/utils_nompi+0x131932d)
879:     #6 0x12ba1a8 in vsprintf (/build/vt/tests/utils_nompi+0x12ba1a8)
879:     #7 0x12bb113 in sprintf (/build/vt/tests/utils_nompi+0x12bb113)
879:     #8 0x136226a in vt::tests::unit::test_if_asan_fails() /vt/tests/unit/utils/test_safe_union.nompi.cc:301:3
879:     #9 0x13626e8 in vt::tests::unit::TestSanitizers_test_if_asan_fails_Test::TestBody()::GTestExpectFatalFailureHelper::Execute() /vt/tests/unit/utils/test_safe_union.nompi.cc:307:3
879:     #10 0x13624fe in vt::tests::unit::TestSanitizers_test_if_asan_fails_Test::TestBody() /vt/tests/unit/utils/test_safe_union.nompi.cc:307:3
879:     #11 0x146946a in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /vt/tests/extern/googletest/googletest/src/gtest.cc:2433:10
879:     #12 0x142d737 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /vt/tests/extern/googletest/googletest/src/gtest.cc:2469:14
879:     #13 0x13e4d49 in testing::Test::Run() /vt/tests/extern/googletest/googletest/src/gtest.cc:2508:5
879:     #14 0x13e6e59 in testing::TestInfo::Run() /vt/tests/extern/googletest/googletest/src/gtest.cc:2684:11
879:     #15 0x13e8124 in testing::TestSuite::Run() /vt/tests/extern/googletest/googletest/src/gtest.cc:2816:28
879:     #16 0x1404565 in testing::internal::UnitTestImpl::RunAllTests() /vt/tests/extern/googletest/googletest/src/gtest.cc:5338:44
879:     #17 0x1471a2a in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /vt/tests/extern/googletest/googletest/src/gtest.cc:2433:10
879:     #18 0x14343f2 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /vt/tests/extern/googletest/googletest/src/gtest.cc:2469:14
879:     #19 0x1403880 in testing::UnitTest::Run() /vt/tests/extern/googletest/googletest/src/gtest.cc:4925:10
879:     #20 0x136b010 in RUN_ALL_TESTS() /vt/tests/extern/googletest/googletest/include/gtest/gtest.h:2473:46
879:     #21 0x1345987 in main /vt/tests/unit/main.cc:66:10
879:     #22 0x7fe2f733b0b2 in __libc_start_main /build/glibc-eX1tMB/glibc-2.31/csu/../csu/libc-start.c:308:16
879:     #23 0x129b19d in _start (/build/vt/tests/utils_nompi+0x129b19d)
879: 
1/1 Test #879: vt:TestSanitizers.test_if_asan_fails_no_mpi ...***Failed  Required regular expression not found. Regex=[PASSED
]  0.19 sec

0% tests passed, 1 tests failed out of 1

If anyone is interested, more info can be found here -> https://llvm.org/docs/CommandGuide/llvm-symbolizer.html

ccache && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
Expand Down
4 changes: 4 additions & 0 deletions cmake-modules/SetCXXCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ elseif (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel")
message(FATAL_ERROR "Your C++ compiler may not support C++14.")
endif ()

if (vt_asan_enabled)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
endif()
endmacro()
11 changes: 3 additions & 8 deletions cmake/load_bundled_libraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,9 @@ endif()

# Check if address sanitizer can be enabled
if (vt_asan_enabled)
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
(CMAKE_CXX_COMPILER_ID
STREQUAL
"GNU"
AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.8"))
if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message(STATUS "Building with address sanitizer enabled")
else()
message(SEND_ERROR "Cannot use ASAN without clang or gcc >= 4.8")
endif()
endif()
2 changes: 1 addition & 1 deletion scripts/workflows-azure.ini
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ vt_pool = 0
vt_asan = 1
output_name = ci/azure/azure-gcc-8-ubuntu-mpich.yml
vt_use_std_thread = 1
lsan_options = suppressions=/vt/tests/knowns_leaks.supp
lsan_options = suppressions=/vt/tests/lsan.supp

[PR-tests-gcc-9]
test_configuration = "gcc-9, ubuntu, mpich, zoltan"
Expand Down
File renamed without changes.