Bug 12753

Summary: [3.3/3.4/4.0 regression] Memory corruption in cpp on bad input
Product: gcc Reporter: H.J. Lu <hjl.tools>
Component: preprocessorAssignee: Zack Weinberg <zack+srcbugz>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs, gdr, neil, zack+srcbugz
Priority: P2 Keywords: ice-on-invalid-code
Version: 3.3.2   
Target Milestone: 3.4.1   
Host: i686-pc-linux-gnu Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu Known to work:
Known to fail: Last reconfirmed: 2003-10-24 11:23:17
Attachments: A testcase (foo.c)
Slightly reduced testcase

Description H.J. Lu 2003-10-24 06:46:38 UTC
# /usr/gcc-3.3/bin/gcc -M -O foo.c
cc1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 H.J. Lu 2003-10-24 06:48:27 UTC
Created attachment 4986 [details]
A testcase (foo.c)

This is the bad input which causes gcc 3.3.2 to dump core.
Comment 2 Christian Ehrhardt 2003-10-24 11:23:15 UTC
Confirmed with 3.3.2-prerelease and 3.4. This is a regression from 3.2.
The trigger is a missing ")" in a macro invokation.
Comment 3 Andrew Pinski 2003-10-24 16:47:00 UTC
From Phil's regression hunter: Search converges between 2002-06-02-trunk (#80) and 2002-07
-14-trunk (#81).
Comment 4 Gabriel Dos Reis 2003-12-24 21:19:27 UTC
CPP maintainers --
Do any of you think this worth fixing in 3.3.x?
Comment 5 Zack Weinberg 2003-12-24 21:28:49 UTC
Yes, I do.

I will look at this, but I would really appreciate a reduced testcase if possible.
Comment 6 Stephan T. Lavavej 2003-12-27 21:32:36 UTC
I spent a little time chopping things out of the test case. It seems to be 
very sensitive to the size of the file. I gave up after chopping 20 KB out of 
the file.

C:\Temp>gcc -M foo2.c
cc1.exe: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.mingw.org/bugs.shtml> for instructions.

C:\Temp>
Comment 7 Stephan T. Lavavej 2003-12-27 21:33:34 UTC
Created attachment 5374 [details]
Slightly reduced testcase
Comment 8 Zack Weinberg 2003-12-27 23:23:36 UTC
Mine.
Comment 9 Gabriel Dos Reis 2004-01-21 04:16:34 UTC
Zack --
I'm going to make a pre-release within two days, do you
think you'll have something ready by then?

Thanks,

-- Gaby
Comment 10 Zack Weinberg 2004-01-21 04:27:08 UTC
Subject: Re:  [3.3/3.4/3.5 regression] Memory
 corruption in cpp on bad input


Sorry, I've been concentrating on the c-decl.c mess in 3.4.

zw
Comment 11 Gabriel Dos Reis 2004-02-15 12:36:08 UTC
Adjust milestone
Comment 12 Mark Mitchell 2004-03-21 18:50:25 UTC
I cannot reproduce this problem in GCC 3.4.0.

Is there a more reliable way of reproducing it?

In any case, I'm retargeting this at 3.4.1.

Gaby and I have already agreed that the 3.4.x target milestones take precedence
over the 3.3.x milestones.  Gaby, please note that this used to be marked as
targeted at 3.3.4, but is now targeted at 3.4.1.
Comment 13 Zack Weinberg 2004-06-01 04:26:41 UTC
IIRC this one was fixed already...?

Has nothing to do with the c-decl.c rewrite, just for the record.
Comment 14 Mark Mitchell 2004-06-09 19:21:54 UTC
Already fixed -- at least for me.  Reopen if this still occurs.