delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/05/04:48:48

Message-ID: <38730022.24617B1@connection.com>
Date: Wed, 05 Jan 2000 03:26:12 -0500
From: sam <samirw AT connection DOT com>
X-Mailer: Mozilla 4.6 [en] (Win95; I)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Array crashes my program!
References: <38729762 DOT 6F966CF7 AT netcom DOT ca> <83bt71t12n DOT fsf AT mercury DOT st DOT hmc DOT edu>
NNTP-Posting-Host: pm2-149.connection.com
X-Trace: 5 Jan 2000 03:40:53 -0500, pm2-149.connection.com
Lines: 35
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Nate Eldredge wrote:

> MM <mm AT netcom DOT ca> writes:
>
> > A simple program of the form
> >  int main (void)
> > {
> >    int array[1000000];
> >    return (0);
> > }
> >
> > continually crashes my program.  The symified error message complains
> > about something called
> > the __djgpp_exceptional_table.
> > If I decrease the size of the array it doesn't crash but leaving it as
> > is or making it bigger makes it crash
> > and I know I have enough ram to address that much memory.
> > Dynamically allocating that amount works fine.  Anyone know what's
> > wrong?
>
> Local arrays in DJGPP programs are allocated on the stack, which is by
> default only 256K.  Your array is clearly much larger, so you overrun
> the stack and your program crashes.  See FAQ section 15.9 for ways to
> enlarge it, but your best bet is not to do it at all; try to find a
> solution involving malloc.
>
> --
>
> Nate Eldredge
> neldredge AT hmc DOT edu

Or just move the declaration to the global space by moving it above main ().



- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019