bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: SIGSEGV with empty grammar file


From: Paul Eggert
Subject: Re: SIGSEGV with empty grammar file
Date: 12 Mar 2003 23:16:55 -0800
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.3

Tim Van Holder <address@hidden> writes:

> (BTW, is it just me who has real problems with the GNU CVS servers
> today?)

I often have problem contacting them; either network access is slow,
or the servers are overloaded; I don't know which.

> When given a completely empty (0 bytes) file as input, CVS bison blows
> chunks.

Thanks for reporting that; I installed the following patch.

2003-03-12  Paul Eggert  <address@hidden>

        * scan-gram.l (YY_USER_INIT): Initialize code_start, too.
        (<INITIAL><<EOF>>, <SC_PRE_CODE><<EOF>>): Set *loc to the scanner
        cursor, instead of leaving it undefined.  This fixes a bug
        reported by Tim Van Holder in
        <http://mail.gnu.org/archive/html/bug-bison/2003-03/msg00023.html>.
        * tests/input.at (Torturing the Scanner): Test the scanner on
        an empty input file, which was Tim Van Holder's test case.

--- src/scan-gram.l     2 Mar 2003 06:55:15 -0000       1.57
+++ src/scan-gram.l     13 Mar 2003 07:07:17 -0000      1.58
@@ -43,6 +43,7 @@
       scanner_cursor.file = current_file;              \
       scanner_cursor.line = 1;                         \
       scanner_cursor.column = 1;                       \
+      code_start = scanner_cursor;                     \
     }                                                  \
   while (0)
 
@@ -279,6 +280,11 @@ splice      (\\[ \f\t\v]*\n)*
   . {
     complain_at (*loc, _("invalid character: %s"), quote (yytext));
   }
+
+  <<EOF>> {
+    loc->start = loc->end = scanner_cursor;
+    yyterminate ();
+  }
 }
 
 
@@ -529,6 +535,8 @@ splice       (\\[ \f\t\v]*\n)*
        return token_type;
       }
   }
+
+  <<EOF>>  unexpected_end_of_file (scanner_cursor, "{}");
 }
 
 
--- tests/input.at      11 Dec 2002 07:00:15 -0000      1.24
+++ tests/input.at      13 Mar 2003 07:05:44 -0000      1.26
@@ -1,5 +1,5 @@
 # Checking the output filenames.                    -*- Autotest -*-
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -91,6 +91,13 @@ AT_CLEANUP
 # we do.
 
 AT_SETUP([Torturing the Scanner])
+
+
+AT_DATA([input.y], [])
+AT_CHECK([bison input.y], [1], [],
+[[input.y:1.1: syntax error, unexpected "end of file"
+]])
+
 
 AT_DATA_GRAMMAR([input.y],
 [[%{




reply via email to

[Prev in Thread] Current Thread [Next in Thread]