diff mbox

Fix -traditional-cpp preprocessing (PR preprocessor/39213)

Message ID 20101217194500.GE2198@tyan-ft48-01.lab.bos.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Dec. 17, 2010, 7:45 p.m. UTC
Hi!

When doing normal preprocessing, the _cpp_process_line_notes call
in _cpp_lex_direct is guarded by !pfile->overlaid_buffer, which I guess
is to avoid comparing unrelated pointers - the .pos field is from the
normal buffer, while cur if pfile->overlaid_buffer is from the overlay,
thus depending on whether that overlay buffer has been allocated above or
below the normal buffer in the address space it will either work or can
crash.

This patch adds the same test to traditional preprocessing.  I've
bootstrapped/regtested it on x86_64-linux and i686-linux and tries to
preprocess a couple of large files with -traditional-cpp without any

	Jakub

Comments

Eric Botcazou Dec. 17, 2010, 10:32 p.m. UTC | #1
> This patch adds the same test to traditional preprocessing.  I've
> bootstrapped/regtested it on x86_64-linux and i686-linux and tries to
> preprocess a couple of large files with -traditional-cpp without any
> difference, but I can't reproduce the original problem.  CCing
> Eric who has managed to reproduce it on Solaris.

I replied earlier today under the PR though, the patch doesn't seem to work 
for me.  I'm ready to dig further of course.
diff mbox

Patch

difference, but I can't reproduce the original problem.  CCing
Eric who has managed to reproduce it on Solaris.

Ok for trunk?

2010-12-17  Jakub Jelinek  <jakub@redhat.com>

	PR preprocessor/39213
	* traditional.c (_cpp_scan_out_logical_line): Don't call
	_cpp_process_line_notes if pfile->overlaid_buffer.

--- libcpp/traditional.c.jj	2009-04-14 16:35:21.000000000 +0200
+++ libcpp/traditional.c	2010-12-17 11:34:18.000000000 +0100
@@ -1,5 +1,5 @@ 
 /* CPP Library - traditional lexical analysis and macro expansion.
-   Copyright (C) 2002, 2004, 2005, 2007, 2008, 2009
+   Copyright (C) 2002, 2004, 2005, 2007, 2008, 2009, 2010
    Free Software Foundation, Inc.
    Contributed by Neil Booth, May 2002
 
@@ -378,7 +378,8 @@  _cpp_scan_out_logical_line (cpp_reader *
   for (;;)
     {
       if (!context->prev
-	  && cur >= pfile->buffer->notes[pfile->buffer->cur_note].pos)
+	  && cur >= pfile->buffer->notes[pfile->buffer->cur_note].pos
+	  && !pfile->overlaid_buffer)
 	{
 	  pfile->buffer->cur = cur;
 	  _cpp_process_line_notes (pfile, false);