[llvm] [llvm-debuginfo-analyzer] Fix a couple of unhandled DWARF situations leading to a crash (PR #137221)

Carlos Alberto Enciso via llvm-commits llvm-commits at lists.llvm.org
Thu May 1 00:01:15 PDT 2025


================
@@ -433,6 +433,13 @@ Error LVBinaryReader::createInstructions(LVScope *Scope,
 
   ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(*SectionContentsOrErr);
   uint64_t Offset = Address - SectionAddress;
+  if (Offset > Bytes.size()) {
+    LLVM_DEBUG({
+      dbgs() << "offset (" << hexValue(Offset) << ") is beyond section size ("
+             << hexValue(Bytes.size()) << "); malformed input?\n";
+    });
+    return Error::success(); // Continue; returning error aborts reader.
+  }
----------------
CarlosAlbertoEnciso wrote:

I think we should handle this condition as an error and abort the reader. May be something like:
```
if (Offset > Bytes.size()) {
  LLVM_DEBUG({.....});
  return createStringError(errc::bad_address, .......);
}
```

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


More information about the llvm-commits mailing list