Skip to content

Conversation

AbhayKanhere
Copy link
Contributor

if asserts are disabled this code can return corrupted memory

I'd like to nominate myself as an additional apple representative
(vendor contact) on the llvm security group.

I met many of you at the llvm-dev meeting roundtable(s) in Santa Clara.
I closely work with @ahmedbougacha @jloerofs at apple.
  When assert() are disabled, this function can return corrupt data.
@llvmbot
Copy link
Member

llvmbot commented Jan 7, 2025

@llvm/pr-subscribers-debuginfo

Author: Abhay Kanhere (AbhayKanhere)

Changes

if asserts are disabled this code can return corrupted memory


Full diff: https://github.com/llvm/llvm-project/pull/122009.diff

1 Files Affected:

  • (modified) llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp (+4-8)
diff --git a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
index a5e6bebcd29c7f..6306476fac657f 100644
--- a/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
+++ b/llvm/lib/CodeGen/LiveDebugValues/VarLocBasedImpl.cpp
@@ -997,13 +997,6 @@ class VarLocBasedLDV : public LDVImpl {
     return *VLS;
   }
 
-  const VarLocSet &getVarLocsInMBB(const MachineBasicBlock *MBB,
-                                   const VarLocInMBB &Locs) const {
-    auto It = Locs.find(MBB);
-    assert(It != Locs.end() && "MBB not in map");
-    return *It->second;
-  }
-
   /// Tests whether this instruction is a spill to a stack location.
   bool isSpillInstruction(const MachineInstr &MI, MachineFunction *MF);
 
@@ -1286,7 +1279,10 @@ void VarLocBasedLDV::printVarLocInMBB(const MachineFunction &MF,
   for (const MachineBasicBlock &BB : MF) {
     if (!V.count(&BB))
       continue;
-    const VarLocSet &L = getVarLocsInMBB(&BB, V);
+    auto It = V.find(&BB);
+    if (It == V.end())
+      continue;
+    const VarLocSet &L = *It->second;
     if (L.empty())
       continue;
     SmallVector<VarLoc, 32> VarLocs;

@AbhayKanhere
Copy link
Contributor Author

fixing merge nodes. discard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants