Skip to content
  • Elvin Alin Sindrilaru's avatar
    CONSOLE: Fix parse_comment function which was corrupting memeory · a139a4c2
    Elvin Alin Sindrilaru authored
    ==15952==ERROR: AddressSanitizer: heap-use-after-free on address 0x6060000fa2f8 at pc 0x7f9e634b8185 bp 0x7ffca6d90e80 sp 0x7ffca6d90628
        #0 0x7f9e634b8184  (/lib64/libasan.so.3+0x46184)
        #1 0x699c14 in testing::internal::String::CStringEquals(char const*, char const*) /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:927
        #2 0x699c14 in testing::internal::CmpHelperSTREQ(char const*, char const*, char const*, char const*) /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:1520
        #3 0x499e44 in ParseComment_CommentExtraction_Test::TestBody() /builds/dss/eos/unit_tests/console/ParseCommentTest.cc:89
        #4 0x6a73a3 in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:2432
        #5 0x6a73a3 in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:2468
        #6 0x694fbd in testing::Test::Run() /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:2507
        #7 0x695563 in testing::Test::Run() /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:2498
        #8 0x695563 in testing::TestInfo::Run() /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:2682
        #9 0x695af4 in testing::TestInfo::Run() /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:2657
        #10 0x695af4 in testing::TestCase::Run() /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:2800
        #11 0x6965ec in testing::TestCase::Run() /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:5176
        #12 0x6965ec in testing::internal::UnitTestImpl::RunAllTests() /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:5124
        #13 0x6a7c73 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:2432
        #14 0x6a7c73 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:2468
        #15 0x696fa5 in testing::UnitTest::Run() /builds/dss/eos/unit_tests/googletest/googletest/src/gtest.cc:4733
        #16 0x47221f in RUN_ALL_TESTS() /builds/dss/eos/unit_tests/googletest/googletest/include/gtest/gtest.h:2329
        #17 0x47221f in main /builds/dss/eos/unit_tests/googletest/googletest/src/gtest_main.cc:37
        #18 0x7f9e5bce3444 in __libc_start_main (/lib64/libc.so.6+0x22444)
        #19 0x475279  (/builds/dss/eos/build/unit_tests/eos-unit-tests+0x475279)
    
    0x6060000fa2f8 is located 24 bytes inside of 62-byte region [0x6060000fa2e0,0x6060000fa31e)
    freed by thread T0 here:
        #0 0x7f9e6353a540 in operator delete(void*) (/lib64/libasan.so.3+0xc8540)
        #1 0x50feba in std::string::_Rep::_M_dispose(std::allocator<char> const&) /opt/rh/devtoolset-6/root/usr/include/c++/6.3.1/bits/basic_string.h:2780
        #2 0x50feba in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() /opt/rh/devtoolset-6/root/usr/include/c++/6.3.1/bits/basic_string.h:3077
        #3 0x50feba in parse_comment(char*, std::string&) /builds/dss/eos/console/ConsoleMain.cc:1214
    
    previously allocated by thread T0 here:
        #0 0x7f9e63539ec0 in operator new(unsigned long) (/lib64/libasan.so.3+0xc7ec0)
        #1 0x7f9e5c87fab8 in std::string::_Rep::_S_create(unsigned long, unsigned long, std::allocator<char> const&) (/lib64/libstdc++.so.6+0xbdab8)
        #2 0x1  (<unknown module>)
    a139a4c2