Blame SOURCES/rhbz1054962.patch

f43afa
From a94b495c5b48324cecff42afce15a4d843577741 Mon Sep 17 00:00:00 2001
f43afa
From: Jonathan Lebon <jlebon@redhat.com>
f43afa
Date: Wed, 13 Nov 2013 12:29:49 -0500
f43afa
Subject: BZ1054962
f43afa
f43afa
BZ1054962: PR16166: assign token to new block
f43afa
f43afa
BZ1054962: stap translator: tolerate NULLs coming from some elfutils string lookups
f43afa
f43afa
It was reported on the mailing list, and privately experienced, that
f43afa
stap pass-2 crashes could occur due to NULL dwarf_diename or
f43afa
dwarf_decl_file's being propagated rather far within stap.  This
f43afa
commit adds protections (of the form ?: "foo") to eliminate the
f43afa
problem in a few spots.  There may be others; we should not store
f43afa
so many raw char*'s.
f43afa
---
f43afa
 dwflpp.cxx  |  4 ++--
f43afa
 tapsets.cxx | 16 +++++++++++-----
f43afa
 2 files changed, 13 insertions(+), 7 deletions(-)
f43afa
f43afa
diff --git a/dwflpp.cxx b/dwflpp.cxx
f43afa
index f8b1517..93713d0 100644
f43afa
--- a/dwflpp.cxx
f43afa
+++ b/dwflpp.cxx
f43afa
@@ -1742,7 +1742,7 @@ dwflpp::iterate_over_labels (Dwarf_Die *begin_die,
f43afa
                 {
f43afa
                   // Get the file/line number for this label
f43afa
                   int dline;
f43afa
-                  const char *file = dwarf_decl_file (&die);
f43afa
+                  const char *file = dwarf_decl_file (&die) ?: "<unknown source>";
f43afa
                   dwarf_decl_line (&die, &dline);
f43afa
 
f43afa
                   vector<Dwarf_Die> scopes = getscopes_die(&die);
f43afa
@@ -2045,7 +2045,7 @@ dwflpp::function_file (char const ** c)
f43afa
 {
f43afa
   assert (function);
f43afa
   assert (c);
f43afa
-  *c = dwarf_decl_file (function);
f43afa
+  *c = dwarf_decl_file (function) ?: "<unknown source>";
f43afa
 }
f43afa
 
f43afa
 
f43afa
diff --git a/tapsets.cxx b/tapsets.cxx
f43afa
index 6dea4d2..205de34 100644
f43afa
--- a/tapsets.cxx
f43afa
+++ b/tapsets.cxx
f43afa
@@ -1683,8 +1683,14 @@ inline_instance_info::operator<(const inline_instance_info& other) const
f43afa
     return decl_line < other.decl_line;
f43afa
 
f43afa
   int cmp = name.compare(other.name);
f43afa
-  if (!cmp)
f43afa
-    cmp = strcmp(decl_file, other.decl_file);
f43afa
+
f43afa
+  if (!cmp) 
f43afa
+    {
f43afa
+      assert (decl_file);
f43afa
+      assert (other.decl_file);
f43afa
+      cmp = strcmp(decl_file, other.decl_file);
f43afa
+    }
f43afa
+
f43afa
   return cmp < 0;
f43afa
 }
f43afa
 
f43afa
@@ -3874,6 +3880,7 @@ dwarf_var_expanding_visitor::visit_perf_op (perf_op *e)
f43afa
   t->content = e_lit_val;
f43afa
 
f43afa
   add_block = new block;
f43afa
+  add_block->tok = e->tok;
f43afa
 
f43afa
   systemtap_session &s = this->q.sess;
f43afa
   map<string, pair<string,derived_probe*> >::iterator it;
f43afa
@@ -4187,8 +4194,7 @@ dwarf_atvar_query::atvar_query_cu (Dwarf_Die * cudie, void * data)
f43afa
 
f43afa
   if (! q->e.cu_name.empty())
f43afa
     {
f43afa
-      const char *die_name = dwarf_diename(cudie);
f43afa
-
f43afa
+      const char *die_name = dwarf_diename(cudie) ?: "";
f43afa
       if (strcmp(die_name, q->e.cu_name.c_str()) != 0 // Perfect match
f43afa
           && fnmatch(q->cu_name_pattern.c_str(), die_name, 0) != 0)
f43afa
         {
f43afa
@@ -9714,7 +9720,7 @@ tracepoint_derived_probe::build_args(dwflpp&, Dwarf_Die& func_die)
f43afa
         {
f43afa
           // build a tracepoint_arg for this parameter
f43afa
           tracepoint_arg tparg;
f43afa
-          tparg.name = dwarf_diename(&arg;;
f43afa
+          tparg.name = dwarf_diename(&arg) ?: "";
f43afa
 
f43afa
           // read the type of this parameter
f43afa
           if (!dwarf_attr_die (&arg, DW_AT_type, &tparg.type_die)
f43afa
-- 
f43afa
1.8.3.1
f43afa