From: toddb@nvr.com (Todd Brunhoff)
Subject: Resend: core dump in cc1
Reply-To: toddb@nvr.com
Organization: GNUs Not Usenet
Distribution: gnu
Date: Sun, 16 Aug 1992 06:36:52 GMT

My appologies for not including the configuration information.  I'll
remember in the future.  Sorry.  Also included
are some related dialog between Jim Wilson and myself (he guessed that the
platform was a Sun)

Gcc version: 2.2.2
Host machine: Sun SPARCstation 2
Host OS: SunOS 4.1.2 (aka Solaris 1.0.1)
Environment: Cshell.
Limits:	cputime         unlimited
	filesize        unlimited
	datasize        524280 kbytes
	stacksize       8192 kbytes
	coredumpsize    unlimited
	memoryuse       unlimited
	descriptors     64 


I have a generated C file, containing only data.  But it is quite
large: 66375 lines, or 1139291 bytes.  The problem is that when
compiled with gcc, it core dumps a file that is 447271344 bytes
(yes, that's 400+ megabytes!) although it has holes in it and really
only occupies 45 megabytes.

I'm certain that this is not kosher behavior :-)

You can ftp a sanitized, able-to-be-compiled-all-on-its-own file
from ~ftp/tmp/gccbug.c at nvr.com (192.82.231.50)

This is gcc 2.2.2.  The compile line is gcc -c gccbug.c.  Thanks.
---------------
internet: toddb@nvr.com                                             c--Q Q
US:       Todd Brunhoff; North Valley Research;                         `
          15262 NW Greenbriar Pkwy; Beaverton, OR  97006                -
Phone:    (503) 531-5707
Fax:      (503) 690-2320
-----------------------------------------------------
Date: Fri, 14 Aug 92 23:12:25 PDT
From: wilson@cygnus.com (Jim Wilson)
To: toddb@nvr.com
Subject: Re:  core dump in cc1


You didn't mention the gcc configuration, which is very important.
I am assuming it was a sun4 compiler, since that is what your last bug
report was for.

	compiled with gcc, it core dumps a file that is 447271344 bytes
	(yes, that's 400+ megabytes!) although it has holes in it and really
	only occupies 45 megabytes.

All Sun OS 4.x core dumps are like this.

	I have a generated C file, containing only data.  But it is quite
	large: 66375 lines, or 1139291 bytes.  The problem is that when

The problem is that you ran out of virtual memory.  At least I did when I
tried it.  Gcc will report this and exit if it can, but there are some 
circumstances where the OS will force the program to core dump, without
giving it a chance to handle the error.

Gcc parses one statement at a time, and then frees the memory needed for
the parse.  You have a single statement, an array initializer, which is
over 2 Megabytes after preprocessing.

You have to either make your virtual memory larger, or make the program
need less memory.

You can reduce memory usage by splitting the monolithic array into
four arrays.

Check your csh limits, you may need to increase them.

You can also reduce memory usage by precomputing array elements, instead
of using macros which expand to complicated expressions.

Jim Wilson
wilson@cygnus.com
gcc2 sparc maintainer
------------------------------------------------------------------------
To: wilson@cygnus.com (Jim Wilson)
Subject: Re: core dump in cc1 
In-reply-to: Your message of Fri, 14 Aug 92 23:12:25 -0700.
             <9208150612.AA29216@cygnus.com> 
Date: Sat, 15 Aug 92 12:08:13 -0700
From: Todd Brunhoff <toddb@nvr.com>

> You didn't mention the gcc configuration, which is very important.
> I am assuming it was a sun4 compiler, since that is what your last bug
> report was for.

My appologies.  But I appreciate your guess, and it is correct.

> 	compiled with gcc, it core dumps a file that is 447271344 bytes
> 	(yes, that's 400+ megabytes!) although it has holes in it and really
> 	only occupies 45 megabytes.
> 
> All Sun OS 4.x core dumps are like this.

That they have holes, I agree.  That they are 400 megabytes in virtual
file size, I disagree.

> 	I have a generated C file, containing only data.  But it is quite
> 	large: 66375 lines, or 1139291 bytes.  The problem is that when
> 
> The problem is that you ran out of virtual memory.

No kidding?  Shucks.  It is set to 500MB data and 8MB stack right now,
so I guess it should be bigger, huh?

Somehow I get the feeling that you are trying to tell me that this
gargantuan usage of a system resource is just fine.  By comparison
the sun compiler uses no more than a megabyte according to ps.  I'll
suggest gently that this is an error and leave it at that.

> You can reduce memory usage by splitting the monolithic array into
> four arrays.
>
> You can also reduce memory usage by precomputing array elements, instead
> of using macros which expand to complicated expressions.

These are suggestions I suspected would work, but am glad to hear that
they are certain.  The path of least resistance for now is to use a
different compiler for this file.  Thanks for the quick response.
---------------
internet: toddb@nvr.com                                             c--Q Q
US:       Todd Brunhoff; North Valley Research;                         `
          15262 NW Greenbriar Pkwy; Beaverton, OR  97006                -
Phone:    (503) 531-5707
Fax:      (503) 690-2320

Newsgroups: gnu.gcc.bug