[incremental] Patch: FYI: fix SEGV
Tom Tromey
tromey@redhat.com
Mon Mar 24 23:53:00 GMT 2008
I'm checking this in on the incremental-compiler branch.
I don't know why I never saw the off-by-one error in c_parser_lex_all
before. We were computing the length of the buffer improperly.
Also, when reusing the last hunk of a compilation unit, can_reuse_hunk
could SEGV. We now handle this situation by setting the parser to
return the EOF token next.
This lets us get partway through the src tree configure script using
the compile server for everything.
Tom
ChangeLog:
2008-03-24 Tom Tromey <tromey@redhat.com>
* c-parser.c (c_parser_lex_all): Fix off-by-one error.
(can_reuse_hunk): Handle end-of-file.
Index: c-parser.c
===================================================================
--- c-parser.c (revision 132956)
+++ c-parser.c (working copy)
@@ -1418,7 +1418,7 @@
c_set_cpp_error_callback (parse_in);
parser->buffer = buffer;
- parser->buffer_length = pos + 1;
+ parser->buffer_length = pos;
timevar_pop (TV_LEX);
}
@@ -2257,7 +2257,14 @@
if (update_parser)
{
parser->first_hunk = info.self_iter;
- parser->next_token = info.self_iter->start_token;
+ if (info.self_iter)
+ parser->next_token = info.self_iter->start_token;
+ else
+ {
+ /* There might not be a next hunk, so point to the EOF
+ marker. */
+ parser->next_token = parser->buffer_length - 1;
+ }
}
/* FIXME: ... hmm... */
parser->tokens_avail = 0;
More information about the Gcc-patches
mailing list