This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[incremental] Patch: FYI: fix SEGV


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;


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