[llvm] 35fd371 - llvm-symbolizer: Don't crash when referencing an invalid CU in a dwp file twice

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 13 17:51:45 PDT 2023


Author: David Blaikie
Date: 2023-03-14T00:49:32Z
New Revision: 35fd37177b9b201f26390fe963767be548c8c2e9

URL: https://github.com/llvm/llvm-project/commit/35fd37177b9b201f26390fe963767be548c8c2e9
DIFF: https://github.com/llvm/llvm-project/commit/35fd37177b9b201f26390fe963767be548c8c2e9.diff

LOG: llvm-symbolizer: Don't crash when referencing an invalid CU in a dwp file twice

Previously we'd stash a null pointer in a sorted vector of CUs - the
next time around, we'd try to do a binary search in that vector (sorting
on a key inside the objects pointed to by the elements of the vector)
which would deref null if we'd stashed a null in there previously.

As a reasonable, but not ideal, workaround - don't stash any result in
the vector - this means every query will produce a new warning
(resulting in duplicate warnings) but better than a crash.

Stashing null in the list could be workable if we also stashed the
offset in a pair - but then all the clients would need to be fixed up
(maybe using a filtering iterator) which seems like overkill for this
uncommon error case.

Added: 
    

Modified: 
    llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index c199e0118a6f9..2fc26fd86ba3d 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -176,7 +176,7 @@ DWARFUnitVector::getUnitForIndexEntry(const DWARFUnitIndex::Entry &E) {
 
   auto U = Parser(Offset, DW_SECT_INFO, nullptr, &E);
   if (!U)
-    U = nullptr;
+    return nullptr;
 
   auto *NewCU = U.get();
   this->insert(CU, std::move(U));


        


More information about the llvm-commits mailing list