From: Hans-Bernhard Broeker Newsgroups: comp.os.msdos.djgpp Subject: Re: Hunting Sigsev Errors Date: 28 Mar 2001 15:42:46 GMT Organization: Aachen University of Technology (RWTH) Lines: 24 Message-ID: <99t0pm$k1n$1@nets3.rz.RWTH-Aachen.DE> References: <3ac02f4b$0$14446$272ea4a1 AT news DOT execpc DOT com> NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de X-Trace: nets3.rz.RWTH-Aachen.DE 985794166 20535 137.226.32.75 (28 Mar 2001 15:42:46 GMT) X-Complaints-To: abuse AT rwth-aachen DOT de NNTP-Posting-Date: 28 Mar 2001 15:42:46 GMT Originator: broeker@ To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Greg Donnells wrote: > Well, I've discovered something interesting regarding SIGSEV errors and gcc > (2.953). Consider the following code fragment: [...] > #define ARRAYMAX 1024 [...] > struct rec { > long index; > char fname[512]; > } allrecs[ARRAYMAX]; This is, as you suspected, your problem. You've just allocated ARRAYMAX times 516 bytes, or 516 KB of memory, on the stack. That's more than the default size of the whole stack, and will, indeed, cause a solid crash. For such large memory blocks, you should never rely on the stack (i.e. automatic variables) to contain them. Use heap storage instead, i.e. malloc() and friends. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.