Bug #89438 LeakSanitizer errors on xplugin unit tests
Submitted: 26 Jan 2018 14:28 Modified: 24 Oct 2018 10:34
Reporter: Laurynas Biveinis (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Document Store: X Plugin Severity:S3 (Non-critical)
Version:8.0.4 OS:Any
Assigned to: CPU Architecture:Any
Tags: addresssanitizer, asan, leaksanitizer, lsan

[26 Jan 2018 14:28] Laurynas Biveinis
Description:
On a system where AddressSanitizer includes LeakSanitizer (e.g. Ubuntu 17.10), X plugin unit tests will report errors:

=================================================================
==1652==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 72 byte(s) in 1 object(s) allocated from:
    #0 0x7f2494845b50 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb50)
    #1 0x56406770e71f in my_raw_malloc /home/laurynas/mysql-8.0.4/mysys/my_malloc.cc:219
    #2 0x56406770e71f in my_malloc /home/laurynas/mysql-8.0.4/mysys/my_malloc.cc:84
    #3 0x5640673d3bc7 in ngs::Request* ngs::allocate_object<ngs::Request, signed char>(signed char const&) /home/laurynas/mysql-8.0.4/rapid/plugin/x/ngs/include/ngs/memory.h:96
    #4 0x5640673d3bc7 in ngs::Client::read_one_message(ngs::Error_code&) /home/laurynas/mysql-8.0.4/rapid/plugin/x/ngs/src/client.cc:589
    #5 0x564065dc823a in ngs::test::Timers_test_suite_read_one_message_custom_read_timeout_Test::TestBody() /home/laurynas/mysql-8.0.4/rapid/unittest/gunit/xplugin/xpl/timeouts_t.cc:221
    #6 0x5640676448d0 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/laurynas/mysql-8.0.4/source_downloads/googletest-release-1.8.0/googletest/src/gtest.cc:2402
    #7 0x5640676448d0 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /home/laurynas/mysql-8.0.4/source_downloads/googletest-release-1.8.0/googletest/src/gtest.cc:2438
    #8 0x56406764558d in testing::Test::Run() /home/laurynas/mysql-8.0.4/source_downloads/googletest-release-1.8.0/googletest/src/gtest.cc:2474
    #9 0x5640676468cf in testing::TestInfo::Run() /home/laurynas/mysql-8.0.4/source_downloads/googletest-release-1.8.0/googletest/src/gtest.cc:2656
    #10 0x5640676481cd in testing::TestCase::Run() /home/laurynas/mysql-8.0.4/source_downloads/googletest-release-1.8.0/googletest/src/gtest.cc:2774
    #11 0x56406764b45a in testing::internal::UnitTestImpl::RunAllTests() /home/laurynas/mysql-8.0.4/source_downloads/googletest-release-1.8.0/googletest/src/gtest.cc:4649
    #12 0x56406764d390 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/laurynas/mysql-8.0.4/source_downloads/googletest-release-1.8.0/googletest/src/gtest.cc:2402
    #13 0x56406764d390 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /home/laurynas/mysql-8.0.4/source_downloads/googletest-release-1.8.0/googletest/src/gtest.cc:2438
    #14 0x56406764ded3 in testing::UnitTest::Run() /home/laurynas/mysql-8.0.4/source_downloads/googletest-release-1.8.0/googletest/src/gtest.cc:4257
    #15 0x5640648c22a5 in RUN_ALL_TESTS() /home/laurynas/mysql-8.0.4/source_downloads/googletest-release-1.8.0/googletest/include/gtest/gtest.h:2233
    #16 0x5640648c22a5 in main /home/laurynas/mysql-8.0.4/rapid/unittest/gunit/xplugin/test_main.cc:41
    #17 0x7f24923ca1c0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x211c0)

... too long to include ...

How to repeat:
cmake -DWITH_ASAN=ON
make
mtr --debug-server 1st --unit-tests --unit-tests-report
[27 Jan 2018 3:14] MySQL Verification Team
Hello Laurynas,

Thank you for the report and feedback!

Thanks,
Umesh
[27 Jan 2018 3:19] MySQL Verification Team
test results

Attachment: 89438_89439.results (application/octet-stream, text), 935.89 KiB.

[24 Oct 2018 10:34] Erlend Dahl
Reproduces on 8.0.4, fixed in 8.0.11.
[24 Oct 2018 10:35] Erlend Dahl
To be precise, the fix is under the heading of

Bug#27436471 MEMORY LEAKS IN XPLUGIN UNIT TESTS