From: Thomas Demmer Newsgroups: comp.os.msdos.djgpp Subject: Re: Bug report: Structs Date: Tue, 28 Jan 1997 08:40:42 +0100 Organization: Lehrstuhl fuer Stroemungsmechanik Lines: 71 Message-ID: <32EDAD7A.794B@LSTM.Ruhr-UNI-Bochum.De> References: <199701220247 DOT UAA37718 AT audumla DOT students DOT wisc DOT edu> NNTP-Posting-Host: bvb.lstm.ruhr-uni-bochum.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit CC: kkunen AT facstaff DOT wisc DOT edu To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Adam Kunen wrote: > > I think this is the right address for bug reports on DOS port of GNU > C... But anyway, I was using GNU C and found that when you have a structure > bigger than 64k it tends to crash. Although I havn't spent time to pinpoint > exactly what is causing the problem, I beleive that it crashes when you make > a function call with a large structure as an argument. I assume that doing > this is okay because gcc doesn't report any warnings or errors, so I've come > to the conclusion: It's a bug! > I hope this helps, > Adam Kunen, > kkunen AT facstaff DOT wisc DOT edu > > PS: I was told to give an example code file to illustrate the problem: > > struct FooType { > char blah[1024][128]; > }; > > void foobar(struct FooType ptr){ > return; > } > > int main(void){ > struct FooType eek; > foobar(eek); > return 0; > } > > Adam "El grande queso" Kunen > kkunen AT facstaff DOT wisc DOT edu This is not a bug, but rather a misfeature. You are doing two things that make the program crash: You have a local 1 MB structure in main on the stack, and you push a copy of that structure on the stack. Thus, you'd need 2 Meg of stack space. Run stubedit on the executable and find that the default stack is 512 k, or so. I'm not sure if you can increase this to 2 Meg and a bit more, but it is for sure better to say void foobar(struct FooType *ptr){ return; } int main(void){ struct FooType *eek; eek = malloc(sizeof FooType); foobar(eek); return 0; } ( Syntax unchecked ) You just move 4 bytes around when calling foobar() instead of 2 Megs. -- Ciao Tom ************************************************************* * Thomas Demmer * * Lehrstuhl fuer Stroemungsmechanik * * Ruhr-Uni-Bochum * * Universitaetsstr. 150 * * D-44780 Bochum * * Tel: +49 234 700 6434 * * Fax: +49 234 709 4162 * * Voice/Fax Box: +49 2561 91371 2056 * * http://www.lstm.ruhr-uni-bochum.de/~demmer * *************************************************************