public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "mjw at redhat dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sources.redhat.com
Subject: [Bug translator/12176] New: string literal at end of file crashes parser
Date: Mon, 01 Nov 2010 10:55:00 -0000	[thread overview]
Message-ID: <bug-12176-1110@http.sourceware.org/bugzilla/> (raw)

http://sourceware.org/bugzilla/show_bug.cgi?id=12176

           Summary: string literal at end of file crashes parser
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: translator
        AssignedTo: systemtap@sources.redhat.com
        ReportedBy: mjw@redhat.com


A string literal at the end of a file crashes the parser:

$ cat testsuite/parseok/end_string.stp 
#! stap -p1

probe begin { log(last_var_is_last_string); exit(); }

// Parser used to barf when last token in a file was a string
global last_var_is_last_string="HelloWorld"

$ gdb stap

% run  testsuite/parseok/end_string.stp

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7e8e8d6 in parser::parse_literal (this=0x7fffffffd050)
    at /home/mark/src/systemtap/parse.cxx:1708
1708       while (peek()->type == tok_string && !input.ate_comment)
(gdb) 
(gdb) bt
#0  0x00007ffff7e8e8d6 in parser::parse_literal (this=0x7fffffffd050)
    at /home/mark/src/systemtap/parse.cxx:1708
#1  0x00007ffff7e8eda0 in parser::parse_global (this=0x7fffffffd050, globals=
    std::vector of length 1, capacity 1 = {...})
    at /home/mark/src/systemtap/parse.cxx:1510
#2  0x00007ffff7e97133 in parser::parse (this=0x7fffffffd050)
    at /home/mark/src/systemtap/parse.cxx:1180
#3  0x00007ffff7e97465 in parse (s=<value optimized out>, 
    n=<value optimized out>, pr=<value optimized out>)
    at /home/mark/src/systemtap/parse.cxx:182
#4  0x00007ffff7e77a11 in passes_0_4 (argc=<value optimized out>, 
    argv=<value optimized out>) at /home/mark/src/systemtap/main.cxx:566
#5  main (argc=<value optimized out>, argv=<value optimized out>)
    at /home/mark/src/systemtap/main.cxx:874

Testing the following patch:

diff --git a/parse.cxx b/parse.cxx
index da3b881..912fef4 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -1705,9 +1705,12 @@ parser::parse_literal ()
       // PR11208: check if the next token is also a string literal;
auto-concat
       // This is complicated to the extent that we need to skip intermediate
wh
       // XXX: but not comments
-      while (peek()->type == tok_string && !input.ate_comment)
-        ls->value.append(next()->content); // consume and append the token
-
+      const token *n = peek();
+      while (n != NULL && n->type == tok_string && !input.ate_comment)
+        {
+          ls->value.append(next()->content); // consume and append the token
+          n = peek();
+        }
       l = ls;
     }
   else

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

             reply	other threads:[~2010-11-01 10:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-01 10:55 mjw at redhat dot com [this message]
2010-11-01 11:18 ` [Bug translator/12176] " mjw at redhat dot com

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=bug-12176-1110@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sources.redhat.com \
    /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).