[PATCH] D136593: [llvm-debuginfo-analyzer] (07/09) - Compare elements - Test case (AddressSanitizer: leaked in allocations)

Carlos Alberto Enciso via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 24 04:40:43 PDT 2022


CarlosAlbertoEnciso created this revision.
CarlosAlbertoEnciso added reviewers: probinson, Orlando, jryans, psamolysov.
CarlosAlbertoEnciso added projects: All, debug-info, LLVM.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, a.sidorin, baloghadamsoftware.
CarlosAlbertoEnciso requested review of this revision.
Herald added a subscriber: llvm-commits.

The test case 'CompareElements' caused a failure in:

https://lab.llvm.org/buildbot#builders/5/builds/28502
https://lab.llvm.org/buildbot#builders/168/builds/9671
`SUMMARY: AddressSanitizer: 2144 byte(s) leaked in 14 allocation(s).`

The `Insert` function conditionally adds the `Child` logical
element to a logical scope. The not added logical elements,
caused the memory leak. Just record them to be destroyed
when the logical reader is destroyed.

Changed `EXPECT_NE` with `ASSERT_NE`.
Missing in the main review.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136593

Files:
  llvm/unittests/DebugInfo/LogicalView/CompareElementsTest.cpp


Index: llvm/unittests/DebugInfo/LogicalView/CompareElementsTest.cpp
===================================================================
--- llvm/unittests/DebugInfo/LogicalView/CompareElementsTest.cpp
+++ llvm/unittests/DebugInfo/LogicalView/CompareElementsTest.cpp
@@ -26,6 +26,10 @@
 //===----------------------------------------------------------------------===//
 // Basic Reader functionality.
 class ReaderTestCompare : public LVReader {
+  // Elements created but not added to any logical scope. They are
+  // deleted when the logical Reader is destroyed.
+  LVAutoSmallVector<LVElement *> OrphanElements;
+
 public:
   // Types.
   LVType *IntegerType = nullptr;
@@ -109,7 +113,7 @@
   Error Err = createScopes();
   ASSERT_THAT_ERROR(std::move(Err), Succeeded());
   Root = getScopesRoot();
-  EXPECT_NE(Root, nullptr);
+  ASSERT_NE(Root, nullptr);
 
   // Create the logical types.
   IntegerType = create<LVType, LVTypeSetFunction>(&LVType::setIsBase);
@@ -199,6 +203,8 @@
   auto Insert = [&](bool Insert, auto *Parent, auto *Child) {
     if (Insert)
       add(Parent, Child);
+    else
+      OrphanElements.push_back(Child);
   };
 
   setCompileUnit(CompileUnit);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136593.470116.patch
Type: text/x-patch
Size: 1182 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221024/960f066e/attachment.bin>


More information about the llvm-commits mailing list