-
Notifications
You must be signed in to change notification settings - Fork 9
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
#1502 break unit tests on Address (asan) #1503
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #1503 +/- ##
===========================================
+ Coverage 83.03% 83.06% +0.03%
===========================================
Files 784 784
Lines 29650 29650
===========================================
+ Hits 24620 24630 +10
+ Misses 5030 5020 -10
|
Would it be possible to add a death test for one or both of these, to ensure that errors are being both caught and reported as expected? |
b1b73bb
to
425e9e7
Compare
@@ -25,6 +25,7 @@ RUN apt-get update -y -q && \ | |||
make-guile \ | |||
libomp5 \ | |||
libomp-dev \ | |||
llvm-10 \ |
There was a problem hiding this comment.
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
425e9e7
to
3fd8d91
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
The changes being made all look fine. It would be good to add a set of suppressions for the reports generated within OpenMPI, so that we could potentially use that as well. Also, there are runtime configuration variables that can control the sanitizers' behavior, of what counts as an error, what to do when one occurs, etc. Maybe those would play a role in carrying this further. |
@PhilMiller I created two issues for that purpose:
Are you okay with merging this PR, and splitting additional work for better visibility? |
To be clear, we should have a test that definitively triggers the sanitizer, and assert that it reports a failure. Is that the case? |
I read the description of the PR to mean that with the code as is before this PR, if a test does trigger ASan, then it is reported as a failure. Is that right? |
@PhilMiller Yes. |
c42a5f1
to
8a50fa1
Compare
Fixes #1502
After going through some experiments it turns out that the problem was only with Open MPI on my machine. After compiling vt in docker with MPICH, all errors are gone. One important observation I made - problems found in Open MPI were reported as warnings, and I wasn't able to force tests to fail. Which might be a good thing - after all it wasn't vt's code that was problematic.
Anyway, I tried artificially make Address Sanitizer complain, and it seems that test fails, or even more - is interrupted, without any additional work, if only ASAN finds something suspicious. But just in case I leave this snippet here, it might come handy someday.
Also for testing such behavior, if ever needed, there is a gtest macro available:
EXPECT_FATAL_FAILURE
, and it could be used for example like this:Although as stated before, in case Asan finds anything, the test breaks, and logs with problem description, are printed.
In the end, all what this PR does is cleaning up mechanism of compiling vt with Address Sanitizer enabled.