delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/01/05/02:56:36

From: Nate Eldredge <neldredge AT hmc DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Array crashes my program!
Date: 04 Jan 2000 23:44:16 -0800
Organization: InterWorld Communications
Lines: 28
Message-ID: <83bt71t12n.fsf@mercury.st.hmc.edu>
References: <38729762 DOT 6F966CF7 AT netcom DOT ca>
NNTP-Posting-Host: mercury.st.hmc.edu
X-Trace: nntp1.interworld.net 947058252 29497 134.173.45.219 (5 Jan 2000 07:44:12 GMT)
X-Complaints-To: usenet AT nntp1 DOT interworld DOT net
NNTP-Posting-Date: 5 Jan 2000 07:44:12 GMT
X-Newsreader: Gnus v5.7/Emacs 20.4
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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

- Raw text -


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