Mail Archives: djgpp/1997/01/28/07:08:22
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 *
*************************************************************
- Raw text -