[binutils-gdb] gprofng: fix Segmentation Fault in DbeInstr::mapPCtoLine

Vladimir Mezentsev vmezents@sourceware.org
Fri Jan 17 16:32:51 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6f5fae607de7aa257cb9c75fb30e306cdc52512f

commit 6f5fae607de7aa257cb9c75fb30e306cdc52512f
Author: Vladimir Mezentsev <vladimir.mezentsev@oracle.com>
Date:   Thu Jan 16 20:29:34 2025 -0800

    gprofng: fix Segmentation Fault in DbeInstr::mapPCtoLine
    
    The bug was filed against gprofng-gui (https://savannah.gnu.org/bugs/?66560).
    
    gprofng/ChangeLog
    2025-01-16  Vladimir Mezentsev  <vladimir.mezentsev@oracle.com>
    
            * src/Hist_data.cc (DbeInstr::mapPCtoLine): Check for null pointer.

Diff:
---
 gprofng/src/Hist_data.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gprofng/src/Hist_data.cc b/gprofng/src/Hist_data.cc
index 334c5e12113..0a373a5d14b 100644
--- a/gprofng/src/Hist_data.cc
+++ b/gprofng/src/Hist_data.cc
@@ -1391,7 +1391,8 @@ DbeInstr::mapPCtoLine (SourceFile *sf)
   if (inlinedInd >= 0)
     {
       DbeLine *dl = func->inlinedSubr[inlinedInd].dbeLine;
-      return dl->sourceFile->find_dbeline (func, dl->lineno);
+      if (dl)
+	return dl->sourceFile->find_dbeline (func, dl->lineno);
     }
   return func->mapPCtoLine (addr, sf);
 }
@@ -1422,7 +1423,9 @@ DbeInstr::add_inlined_info (StringBuilder *sb)
 	      sb->append (' ');
 	    }
 	  DbeLine *dl = p->dbeLine;
-	  sb->appendf (NTXT ("%s:%lld <-- "), get_basename (dl->sourceFile->get_name ()), (long long) dl->lineno);
+	  if (dl)
+	    sb->appendf ("%s:%lld <-- ", get_basename (dl->sourceFile->get_name ()),
+		     (long long) dl->lineno);
 	}
       last = p;
     }


More information about the Binutils-cvs mailing list