[PATCH] D137152: Fix crash when using embedded DWARF-5 debugging info

Guilherme Amadio via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 1 03:44:48 PDT 2022


amadio created this revision.
amadio added a reviewer: v.g.vassilev.
Herald added a project: All.
amadio requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

A nullptr dereference happens in DIFile when Source is non-null, but
*Source is null, as only Source is checked. The crash happens when
using embedded DWARF-5 debugging info in combination with the GDB
JIT event listener to debug JIT-compiled code within cling/ROOT.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137152

Files:
  llvm/include/llvm/IR/DebugInfoMetadata.h


Index: llvm/include/llvm/IR/DebugInfoMetadata.h
===================================================================
--- llvm/include/llvm/IR/DebugInfoMetadata.h
+++ llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -618,7 +618,7 @@
     return StringRefChecksum;
   }
   Optional<StringRef> getSource() const {
-    return Source ? Optional<StringRef>((*Source)->getString()) : None;
+    return (Source && *Source) ? Optional<StringRef>((*Source)->getString()) : None;
   }
 
   MDString *getRawFilename() const { return getOperandAs<MDString>(0); }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137152.472252.patch
Type: text/x-patch
Size: 545 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221101/903ac402/attachment.bin>


More information about the llvm-commits mailing list