[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bison 1.875 coredump
From: |
Paul Eggert |
Subject: |
Re: Bison 1.875 coredump |
Date: |
02 Apr 2003 13:08:13 -0800 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 |
Paul Govereau <address@hidden> writes:
> I have done a little bit of investigation, and it seems like
> the problem is parse-gram.y calling into reader.c with an invalid
> pointer (loc.start.file). I have attached a stack trace below. Also, I
> noticed that if I run bison with "--trace=scan" or "--trace=parse" it
> does not crash, and seems to work fine. Once again, my inputs are:
>
> %% A : B %% --> core dump
> %% A : B; %% --> works fine
> %% A : B --> works fine
Thanks for the details. On further investigation, I think this may
have been fixed in the latest CVS version of Bison. Please try the
following cumulative patch relative to Bison 1.875a.
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>.
2003-03-01 Paul Eggert <address@hidden>
* src/scan-gram.l (code_start): Initialize it to scanner_cursor,
not loc->end, since loc->end might contain garbage and this leads
to undefined behavior on some platforms.
(id_loc, token_start): Use (IF_LINTed) initial values that do not
depend on *loc, so that the reader doesn't give the the false
impression that *loc is initialized.
(<INITIAL>"%%"): Do not bother setting code_start, since its value
does not survive the return.
2003-03-01 Akim Demaille <address@hidden>
* src/scan-gram.l (code_start): Always initialize it when entering
into yylex, as SC_EPILOGUE is activated *before* the corresponding
yylex invocation. An alternative would be making it static, but
then it starts with the second %%'s beginning, instead of its end.
2003-02-03 Paul Eggert <address@hidden>
* src/scan-gram.l (no_cr_read): Use bytes_read, not s, for size
var.
Index: scan-gram.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-gram.l,v
retrieving revision 1.54
retrieving revision 1.58
diff -p -u -r1.54 -r1.58
--- scan-gram.l 31 Dec 2002 02:26:51 -0000 1.54
+++ scan-gram.l 13 Mar 2003 07:07:17 -0000 1.58
@@ -1,6 +1,6 @@
/* Bison Grammar Scanner -*- C -*-
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -43,6 +43,7 @@
scanner_cursor.file = current_file; \
scanner_cursor.line = 1; \
scanner_cursor.column = 1; \
+ code_start = scanner_cursor; \
} \
while (0)
@@ -136,14 +137,16 @@ splice (\\[ \f\t\v]*\n)*
int token_type IF_LINT (= 0);
/* Location of most recent identifier, when applicable. */
- location id_loc IF_LINT (= *loc);
+ location id_loc IF_LINT (= empty_location);
- /* Where containing code started, when applicable. */
- boundary code_start IF_LINT (= loc->start);
+ /* Where containing code started, when applicable. Its initial
+ value is relevant only when yylex is invoked in the SC_EPILOGUE
+ start condition. */
+ boundary code_start = scanner_cursor;
/* Where containing comment or string or character literal started,
when applicable. */
- boundary token_start IF_LINT (= loc->start);
+ boundary token_start IF_LINT (= scanner_cursor);
%}
@@ -270,16 +273,18 @@ splice (\\[ \f\t\v]*\n)*
"%%" {
static int percent_percent_count;
if (++percent_percent_count == 2)
- {
- code_start = loc->start;
- BEGIN SC_EPILOGUE;
- }
+ BEGIN SC_EPILOGUE;
return PERCENT_PERCENT;
}
. {
complain_at (*loc, _("invalid character: %s"), quote (yytext));
}
+
+ <<EOF>> {
+ loc->start = loc->end = scanner_cursor;
+ yyterminate ();
+ }
}
@@ -530,6 +535,8 @@ splice (\\[ \f\t\v]*\n)*
return token_type;
}
}
+
+ <<EOF>> unexpected_end_of_file (scanner_cursor, "{}");
}
@@ -682,14 +689,14 @@ adjust_location (location *loc, char con
static size_t
no_cr_read (FILE *fp, char *buf, size_t size)
{
- size_t s = fread (buf, 1, size, fp);
- if (s)
+ size_t bytes_read = fread (buf, 1, size, fp);
+ if (bytes_read)
{
- char *w = memchr (buf, '\r', s);
+ char *w = memchr (buf, '\r', bytes_read);
if (w)
{
char const *r = ++w;
- char const *lim = buf + s;
+ char const *lim = buf + bytes_read;
for (;;)
{
@@ -718,7 +725,7 @@ no_cr_read (FILE *fp, char *buf, size_t
}
}
- return s;
+ return bytes_read;
}