Bug 5470 - stap segfaults on parseko/probepoint08.stp
Summary: stap segfaults on parseko/probepoint08.stp
Status: RESOLVED FIXED
Alias: None
Product: systemtap
Classification: Unclassified
Component: translator (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Wenji Huang
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-11 19:06 UTC by Martin Hunt
Modified: 2007-12-12 16:18 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Hunt 2007-12-11 19:06:48 UTC
stap from CVS on Fedora 8 x86_64

> stap probepoint08.stp
Segmentation fault
Comment 1 Wenji Huang 2007-12-12 02:52:11 UTC
> stap from CVS on Fedora 8 x86_64
> 
> > stap probepoint08.stp
> Segmentation fault

I can also reproduce it. Seems that stap can't handle the unexpected end of file
well.

Created a short patch for it. Please review it.

--- src/parse.cxx       2007-12-12 09:07:12.000000000 -0500
+++ src.new/parse.cxx   2007-12-12 09:00:36.000000000 -0500
@@ -1343,14 +1343,14 @@ parser::parse_probe_point ()
         {
           next ();
           t = peek ();
-          if (! (t->type == tok_operator && t->content == "("))
+          if (t && ! (t->type == tok_operator && t->content == "("))
             throw parse_error ("expected '('");
           next ();

           pl->condition = parse_expression ();

           t = peek ();
-          if (! (t->type == tok_operator && t->content == ")"))
+          if (t && ! (t->type == tok_operator && t->content == ")"))
             throw parse_error ("expected ')'");
           next ();
Comment 2 Frank Ch. Eigler 2007-12-12 03:42:02 UTC
Nice patch, thanks.
Comment 3 Masami Hiramatsu 2007-12-12 14:47:55 UTC
(In reply to comment #1)
> > stap from CVS on Fedora 8 x86_64
> > 
> > > stap probepoint08.stp
> > Segmentation fault
> 
> I can also reproduce it. Seems that stap can't handle the unexpected end of file
> well.
> 
> Created a short patch for it. Please review it.

This patch will report "expected '('" error, 
but I think 'unexpected eof' error is better.

Comment 4 Frank Ch. Eigler 2007-12-12 15:00:17 UTC
(In reply to comment #3)
> This patch will report "expected '('" error, 
> but I think 'unexpected eof' error is better.

The complete message should already say something like
"encountered EOF, expected '('".
Comment 5 Masami Hiramatsu 2007-12-12 15:20:28 UTC
(In reply to comment #4)
> The complete message should already say something like
> "encountered EOF, expected '('".

Sure, I just mentioned about the consistency of error messages.
(comparing the output of 'probe p if' and 'probe p { if'.)

Anyway, it's trivial.
Now the segmentation fault bug was fixed. Thank you Wenji.
Comment 6 Masami Hiramatsu 2007-12-12 15:25:58 UTC
Sorry, I was misunderstanding your patch.
It causes 'unexpecetd eof' correctly.

Comment 7 Martin Hunt 2007-12-12 16:18:19 UTC
Works for me.  I also checked in testsuite changes to detect stap crashing and
mark those tests as failed.