Bug 26774 - [4.0 Regression] Out of memory compiling 9-line Delta-reduced Linux kernel driver msp3400.c
Summary: [4.0 Regression] Out of memory compiling 9-line Delta-reduced Linux kernel dr...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.1.0
: P3 normal
Target Milestone: 4.1.1
Assignee: Not yet assigned to anyone
URL:
Keywords: error-recovery, ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2006-03-21 04:19 UTC by Flash Sheridan
Modified: 2007-02-03 16:25 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu, powerpc-apple-darwin8.5.0
Target:
Build:
Known to work: 3.4.6 4.1.1 4.2.0
Known to fail: 4.0.3 4.1.0
Last reconfirmed: 2006-03-21 09:37:33


Attachments
Delta-reduced version (151 bytes, text/plain)
2006-03-21 04:22 UTC, Flash Sheridan
Details
Unreduced preprocessed file (33.88 KB, text/plain)
2006-03-21 04:23 UTC, Flash Sheridan
Details
Fix parser error handling (1.39 KB, patch)
2006-04-04 15:00 UTC, Carlos O'Donell
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Flash Sheridan 2006-03-21 04:19:24 UTC
The attached 9-line file causes a checking=all build of GCC 4.1.0 to exhaust memory, on both Ubuntu Linux 5.04/2.6.10-6-386 and Mac OSX 10.4.5.  It's a Delta-reduced version of a preprocessed version of the Linux Kernel file drivers/media/video/msp3400.c, which exhibited the same behavior.  The original compilation was being done by a test script outside the kernel tree, so the compilation encountered errors; the preprocessed file is invalid C, as is the Delta-reduced version.
    My checking=all builds of GCC 4.0.1 (patched) and 4.02 each give a segmentation fault.  GCC 3.3.5 (Debian 1:3.3.5-8ubuntu2) gives up cleanly: "confused by earlier errors, bailing out".
    On the non-reduced preprocessed file, with my patched checking build of 4.0.1, I instead get the following, which seems like PR22028, which is presumably fixed: 
        internal compiler error: tree check: expected class ‘type’, have ‘exceptional’ (error_mark) in 
        gimplify_type_sizes, at gimplify.c:4368

    Here's the session; I'll attached the preprocessed file and the Delta-reduction.  I used ulimit on Ubuntu to save time; fully exhausting memory on OSX (where ulimit doesn't seem to work) with the unreduced file took half an hour, but memory use gets above 50MB fairly quickly.

3> ulimit -m 50000 -v 50000
 flash@traska scripts 20:11:53
4> /opt/gcc410-chk-all/bin/gcc -v ../cpp/bugfiles/GCC_bugfiles/error/122285_msp3400_min.i
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: /opt/Gcc-4.1.0-dist/configure --enable-checking=all --prefix=/opt/gcc410-chk-all --enable-languages=c,c++ --with-comment=PalmSource checking=all build by Flash Sheridan 3/17/06
Thread model: posix
gcc version 4.1.0
 /home/opt/gcc410-chk-all/bin/../libexec/gcc/i686-pc-linux-gnu/4.1.0/cc1 -fpreprocessed ../cpp/bugfiles/GCC_bugfiles/error/122285_msp3400_min.i -quiet -dumpbase 122285_msp3400_min.i -mtune=pentiumpro -auxbase 122285_msp3400_min -version -o /tmp/ccV7UEre.s
GNU C version 4.1.0 (i686-pc-linux-gnu)
        compiled by GNU C version 3.3.5 (Debian 1:3.3.5-8ubuntu2).
GGC heuristics: --param ggc-min-expand=0 --param ggc-min-heapsize=0
Compiler executable checksum: a68040354320563d9f0f04c1edf3c815
../cpp/bugfiles/GCC_bugfiles/error/122285_msp3400_min.i:3: warning: ‘struct i2c_client’ declared inside parameter list
../cpp/bugfiles/GCC_bugfiles/error/122285_msp3400_min.i:3: warning: its scope is only this definition or declaration, which is probably not what you want
../cpp/bugfiles/GCC_bugfiles/error/122285_msp3400_min.i:4: error: field ‘driver’ has incomplete type
../cpp/bugfiles/GCC_bugfiles/error/122285_msp3400_min.i:6: error: two or more data types in declaration specifiers
../cpp/bugfiles/GCC_bugfiles/error/122285_msp3400_min.i:6: warning: ‘struct i2c_client’ declared inside parameter list
../cpp/bugfiles/GCC_bugfiles/error/122285_msp3400_min.i:8: warning: initialization from incompatible pointer type
virtual memory exhausted: Cannot allocate memory
 flash@traska scripts 20:14:31


---
PalmSource bug #122285
http://pobox.com/~flash
Quality Lead for Compilers and Debuggers
PalmSource, Inc. Tools Quality Management
Comment 1 Flash Sheridan 2006-03-21 04:22:37 UTC
Created attachment 11075 [details]
Delta-reduced version
Comment 2 Flash Sheridan 2006-03-21 04:23:10 UTC
Created attachment 11076 [details]
Unreduced preprocessed file
Comment 3 Richard Biener 2006-03-21 09:37:33 UTC
Confirmed.  Though the unreduced testcase does not build for me.  The testcase
in question is

struct i2c_driver {
 struct module *owner;
 int (*command)(struct i2c_client *client,unsigned int cmd, void *arg);
 struct device_driver driver;
}
static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg);
static struct i2c_driver driver = {
        .command = msp_command,
},
Comment 4 Richard Biener 2006-03-21 09:38:44 UTC
3.4 is confused by earlier errors and bails out.
Comment 5 Carlos O'Donell 2006-04-04 15:00:14 UTC
Created attachment 11201 [details]
Fix parser error handling

The patch fixes this issue. No regressions on i686-pc-linux-gnu.
Comment 6 Carlos O'Donell 2006-04-04 15:01:12 UTC
I'll submit the patch to gcc-patches and check it in when approved.
Comment 7 Carlos O'Donell 2006-04-20 00:21:55 UTC
Subject: Bug 26774

Author: carlos
Date: Thu Apr 20 00:21:51 2006
New Revision: 113107

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113107
Log:
gcc/

2006-04-19  Carlos O'Donell  <carlos@codesourcery.com>
	    Nathan Sidwell  <nathan@codesourcery.com>

	PR c/26774
	* stor-layout.c (update_alignment_for_field): Do not align 
	ERROR_MARK nodes.
	(place_union_field): Place union field at the start of the union.
	(place_field): Move ERROR_MARK check later, and use the current
	allocation position to maintain monotonicity.

gcc/testsuite/

2006-04-19  Carlos O'Donell  <carlos@codesourcery.com>

	PR c/26774
	* gcc.dg/struct-parse-1.c: New test case.


Added:
    trunk/gcc/testsuite/gcc.dg/struct-parse-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/stor-layout.c
    trunk/gcc/testsuite/ChangeLog

Comment 8 Carlos O'Donell 2006-04-21 23:43:00 UTC
Subject: Bug 26774

Author: carlos
Date: Fri Apr 21 23:42:43 2006
New Revision: 113155

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113155
Log:

gcc/

2006-04-21  Carlos O'Donell  <carlos@codesourcery.com>
	
	Backport from mainline:
	2006-04-19  Carlos O'Donell  <carlos@codesourcery.com>
		    Nathan Sidwell  <nathan@codesourcery.com>
	PR c/26774
	* stor-layout.c (update_alignment_for_field): Do not align 
	ERROR_MARK nodes.
	(place_union_field): Place union field at the start of the union.
	(place_field): Move ERROR_MARK check later, and use the current
	allocation position to maintain monotonicity.

gcc/testsuite/

2006-04-21  Carlos O'Donell  <carlos@codesourcery.com>

	Backport from mainline:
	2006-04-19  Carlos O'Donell  <carlos@codesourcery.com>
	PR c/26774
	* gcc.dg/struct-parse-1.c: New test case.


Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/struct-parse-1.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/stor-layout.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog

Comment 9 Gabriel Dos Reis 2007-02-03 16:25:59 UTC
Fixed in GCC-4.1.1