From: "Wenji Huang" <wenji.huang@oracle.com>
To: "systemtap@sourceware.org" <systemtap@sourceware.org>
Subject: [RFC PATCH] Fix segmentation fault of listing kprocess.create
Date: Thu, 05 Nov 2009 05:03:00 -0000 [thread overview]
Message-ID: <20091105130553500.00000001428@ETSD-Ora-lap2> (raw)
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);
next reply other threads:[~2009-11-05 5:03 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-05 5:03 Wenji Huang [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091105130553500.00000001428@ETSD-Ora-lap2 \
--to=wenji.huang@oracle.com \
--cc=systemtap@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).