public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [RFC PATCH] Fix segmentation fault of listing kprocess.create
@ 2009-11-05  5:03 Wenji Huang
  2009-11-05  7:00 ` Wenji Huang
  0 siblings, 1 reply; 7+ messages in thread
From: Wenji Huang @ 2009-11-05  5:03 UTC (permalink / raw)
  To: systemtap

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);

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-11-07  0:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-05  5:03 [RFC PATCH] Fix segmentation fault of listing kprocess.create Wenji Huang
2009-11-05  7:00 ` Wenji Huang
2009-11-05  7:36   ` Wenji Huang
2009-11-05 14:12     ` Frank Ch. Eigler
2009-11-06  1:08       ` Wenji Huang
2009-11-06 11:19         ` Frank Ch. Eigler
2009-11-07  0:14     ` Josh Stone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).