This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC PATCH] Fix segmentation fault of listing kprocess.create


Hi,

I got the Segmentation fault when executing stap -L kprocess.create for latest
source. The same issue happens on FC11 32bits and RHEL5U2 (64bits 2.6.32 kernel),
with elfutils 0.141-0.143. But  'probe kprocess.create{print(task) print(new_pid) print($$parms)}'
works fine on those machines.

The error is from systemtap_session::print_token, invalid pointer 'tok->location.file'
I am not sure what can cause that.  There is one workaround for this error. Moreover,
I think it's necessary to do some sanity checking when referring to pointer.

Example:
$ stap -L kprocess.create
semantic error: probe_1856 with unresolved type: junk '' at unknown file:0:0
semantic error: probe_1856 with unresolved type: unknown token '' at unknown file:0:0
kprocess.create new_pid:long task:long $cgroup_callbacks_done:int $child_tidptr:int* $clone_flags:long unsigned int $p:struct task_struct* $pid:struct pid* $regs:struct pt_regs* $return:struct task_struct* $retval:int $stack_size:long unsigned int $stack_start:long unsigned int $trace:int

diff --git a/elaborate.cxx b/elaborate.cxx
index 626db28..32fb47f 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -1556,9 +1556,11 @@ systemtap_session::print_token (ostream& o, const token* tok)
       tmpo << *tok;
       string ts = tmpo.str();
       // search & replace the file name with nothing
-      size_t idx = ts.find (tok->location.file->name);
-      if (idx != string::npos)
-          ts.replace (idx, tok->location.file->name.size(), "");
+      if (tok->location.file) {
+         size_t idx = ts.find (tok->location.file->name);
+         if (idx != string::npos)
+            ts.replace (idx, tok->location.file->name.size(), "");
+      }

       o << ts;
     }
diff --git a/parse.cxx b/parse.cxx
index cfefa12..5b9005f 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -91,8 +91,11 @@ tt2str(token_type tt)
 ostream&
 operator << (ostream& o, const source_loc& loc)
 {
-  o << loc.file->name << ":"
-    << loc.line << ":"
+  if (loc.file)
+     o << loc.file->name << ":";
+  else
+     o << "unknown file" << ":";
+  o << loc.line << ":"
     << loc.column;

   return o;
diff --git a/parse.h b/parse.h
index 5587586..2b21f65 100644
--- a/parse.h
+++ b/parse.h
@@ -26,6 +26,8 @@ struct source_loc
   stapfile* file;
   unsigned line;
   unsigned column;
+  source_loc():
+    file(0),line(0),column(0) {}
 };

 std::ostream& operator << (std::ostream& o, const source_loc& loc);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]