[Lldb-commits] [clang] [lldb] [Serialization] Support loading template specializations lazily (PR #119333)

Ilya Biryukov via lldb-commits lldb-commits at lists.llvm.org
Thu Dec 12 02:07:02 PST 2024


ilya-biryukov wrote:

@ChuanqiXu9 the added test fails under ASAN that reports memory leaks:

```
$ cmake -G Ninja -DLLVM_USE_SANITIZER=Address -DCMAKE_CXX_COMPILER=clang -DCMAKE_C_COMPILER=clang ../
$ ninja SerializationTests
$ ./tools/clang/unittests/Serialization/SerializationTests
```

produces
```
==4100640==ERROR: LeakSanitizer: detected memory leaks

Indirect leak of 32776 byte(s) in 1 object(s) allocated from:
    #0 0x559f90ba330c in calloc (/usr/local/google/home/ibiryukov/code/llvm-project/build-asan/tools/clang/unittests/Serialization/SerializationTests+0x174d30c) (BuildId: 4baf7bfc387b0be3)
    #1 0x559f910585eb in safe_calloc /usr/local/google/home/ibiryukov/code/llvm-project/llvm/include/llvm/Support/MemAlloc.h:40:18
    #2 0x559f910585eb in AllocateBuckets /usr/local/google/home/ibiryukov/code/llvm-project/llvm/lib/Support/FoldingSet.cpp:173:40
    #3 0x559f910585eb in llvm::FoldingSetBase::FoldingSetBase(unsigned int) /usr/local/google/home/ibiryukov/code/llvm-project/llvm/lib/Support/FoldingSet.cpp:187:13
    #4 0x559f90f34503 in FoldingSetImpl /usr/local/google/home/ibiryukov/code/llvm-project/llvm/include/llvm/ADT/FoldingSet.h:454:9
    #5 0x559f90f34503 in ContextualFoldingSet /usr/local/google/home/ibiryukov/code/llvm-project/llvm/include/llvm/ADT/FoldingSet.h:636:9
    #6 0x559f90f34503 in clang::ASTContext::ASTContext(clang::LangOptions&, clang::SourceManager&, clang::IdentifierTable&, clang::SelectorTable&, clang::Builtin::Context&, clang::TranslationUnitKind) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/AST/ASTContext.cpp:920:7
    #7 0x559f92667204 in clang::CompilerInstance::createASTContext() /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:553:23
    #8 0x559f928ad79a in clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Frontend/FrontendAction.cpp:948:10
    #9 0x559f9266fb7d in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /usr/local/google/home/ibiryukov/code/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1061:13
    #10 0x559f90c13901 in (anonymous namespace)::LoadSpecLazilyTest::GenerateModuleInterface[abi:cxx11](llvm::StringRef, llvm::StringRef) /usr/local/google/home/ibiryukov/code/llvm-project/clang/unittests/Serialization/LoadSpecLazilyTest.cpp:86:5
    #11 0x559f90c18b8b in (anonymous namespace)::LoadSpecLazilyTest_ChainedTest2_Test::TestBody() /usr/local/google/home/ibiryukov/code/llvm-project/clang/unittests/Serialization/LoadSpecLazilyTest.cpp:227:3
    #12 0x559f90e46395 in HandleExceptionsInMethodIfSupported<testing::Test, void> /usr/local/google/home/ibiryukov/code/llvm-project/third-party/unittest/googletest/src/gtest.cc
    #13 0x559f90e46395 in testing::Test::Run() /usr/local/google/home/ibiryukov/code/llvm-project/third-party/unittest/googletest/src/gtest.cc:2687:5
    #14 0x559f90e48ae2 in testing::TestInfo::Run() /usr/local/google/home/ibiryukov/code/llvm-project/third-party/unittest/googletest/src/gtest.cc:2836:11
    #15 0x559f90e4ad74 in testing::TestSuite::Run() /usr/local/google/home/ibiryukov/code/llvm-project/third-party/unittest/googletest/src/gtest.cc:3015:30
    #16 0x559f90e82ee8 in testing::internal::UnitTestImpl::RunAllTests() /usr/local/google/home/ibiryukov/code/llvm-project/third-party/unittest/googletest/src/gtest.cc:5920:44
    #17 0x559f90e811c7 in HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool> /usr/local/google/home/ibiryukov/code/llvm-project/third-party/unittest/googletest/src/gtest.cc
    #18 0x559f90e811c7 in testing::UnitTest::Run() /usr/local/google/home/ibiryukov/code/llvm-project/third-party/unittest/googletest/src/gtest.cc:5484:10
    #19 0x559f90e08bfa in RUN_ALL_TESTS /usr/local/google/home/ibiryukov/code/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:2317:73
    #20 0x559f90e08bfa in main /usr/local/google/home/ibiryukov/code/llvm-project/third-party/unittest/UnitTestMain/TestMain.cpp:55:10
    #21 0x7f0546213c89 in __libc_start_call_main csu/../sysdeps/nptl/libc_start_call_main.h:58:16
...
SUMMARY: AddressSanitizer: 488922 byte(s) leaked in 529 allocation(s).
```

Maybe revert the change or is there a simple fix forward?

https://github.com/llvm/llvm-project/pull/119333


More information about the lldb-commits mailing list