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]

[Bug translator/12176] New: string literal at end of file crashes parser


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.


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