This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: main() {char data[10000000];} crashes on alpha


On Fri, Jan 26, 2001 at 12:16:17AM +0100, Matthias Klose wrote:
> [ http://bugs.debian.org/65364 submitted to the Debian BTS;
>   please CC 65364@bugs.debian.org on replies]
> 
> same behaviour at least in CVS 20010102.
> 
> falk@borkum:~/src/pq% cat bug.c       
> int main() {
>   char data[10000000];
> 
>   return 0;
> }
> falk@borkum:~/src/pq% gcc bug.c -o bug
> falk@borkum:~/src/pq% ./bug           
> zsh: segmentation fault (core dumped)  ./bug
> 
> Slightly less, like 5000000, works ok.
> 
> I have 128 MB of memory, so that shouldn't be the problem.
> 
> It also works on i386.

I suspect you need to have more stack space available.  If you use bash as your
shell, do "ulimit -a" to find out your limits.  If you use csh or tcsh as your
shell do "limit".  If you don't have enough stack space, the program will
segfault when the main function is entered.  In order to raise your stack
limit, you generally have to have a root program use setrlimit to raise the
limit, and then spawn a child (presumably non-root) which would inherit the new
limit.  On some systems you won't be able to raise the limit past a given
amount.

-- 
Michael Meissner, Red Hat, Inc.  (GCC group)
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:	  meissner@redhat.com		phone: +1 978-486-9304
Non-work: meissner@spectacle-pond.org	fax:   +1 978-692-4482

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]