This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: A simple program with a large array segfaults
- From: Andrew Haley <aph at redhat dot com>
- To: "Gowri Kumar CH" <gkumar007 at gmail dot com>
- Cc: "Andrew Pinski" <pinskia at physics dot uc dot edu>, gcc-help at gcc dot gnu dot org
- Date: Thu, 4 Jan 2007 16:52:15 +0000
- Subject: Re: A simple program with a large array segfaults
- References: <526520db0701040411y7c7af69es51c99aaa091e063d@mail.gmail.com> <200701041218.l04CIpc9027245@localhost.localdomain> <526520db0701040849n6845e5bdqe6c9313cb010a091@mail.gmail.com>
[redirected to gcc-help]
Gowri Kumar CH writes:
> Hi andrew,
> >You just overflowed your stack. Increase the stack size for the program
> > by using limit/ulimit or use dynamic allocated memory.
> Thanks for the quick reply. By changing the size of the stack the
> error goes away.
>
> Is this one of the things which we come to know by experience?
> Or
> Is there a way to find it out from the core/code generated?
> This was a simple program with just a few lines. I'm wondering how
> difficult it would be find this sort of errors in a large program.
>
It's just something you learn not to do. Small data on the stack,
large data on the heap.
Andrew.