* segmentation fault with a large array declaration
@ 1997-04-04 5:00 Matthew Temple
1997-04-07 4:00 ` Burkhard Neidecker-Lutz
0 siblings, 1 reply; 2+ messages in thread
From: Matthew Temple @ 1997-04-04 5:00 UTC (permalink / raw)
Given the following program fragment:
#include <stdio.h>
void main(int argc,char *argv[])
{
unsigned char image_buffer[2094041];
/* 2094040 works; 2094041 does not. Note that this is
dependent on the total amount of memory requested,
not just this array and 2^21=2097152*/
int ix;
printf(" Test start. \n");
printf(" Test end. \n");
}
The above program fails with a "segmentation fault" and a core dump
under Digital Unix 3.2C when compiled with either CC or GCC. The SAME
PROGRAM, when compiled on a DU 4.0B machine, runs successfully. In
fact, I can copy the executable from the 4.0B machine to a 3.2C machine
and it will run successfully. Moving the "unsigned" declaration into
a "static" definition before "main" also works.
Can this be explained or fixed?
Matthew Temple
HHMI / HMS Genetics
200 Longwood Ave
Boston, MA 02115
Manager@rascal.med.harvard.edu
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: segmentation fault with a large array declaration
1997-04-04 5:00 segmentation fault with a large array declaration Matthew Temple
@ 1997-04-07 4:00 ` Burkhard Neidecker-Lutz
0 siblings, 0 replies; 2+ messages in thread
From: Burkhard Neidecker-Lutz @ 1997-04-07 4:00 UTC (permalink / raw)
In article <33454134.B80DDF0@compfac.tch.harvard.edu> Matthew Temple <manager@compfac.tch.harvard.edu> writes:
>Given the following program fragment:
> <code with a large automatic array declaration deleted>
>
>The above program fails with a "segmentation fault" and a core dump
>under Digital Unix 3.2C when compiled with either CC or GCC. The SAME
>PROGRAM, when compiled on a DU 4.0B machine, runs successfully. In
>fact, I can copy the executable from the 4.0B machine to a 3.2C machine
>and it will run successfully.
>Can this be explained or fixed?
On 3.2 you are running against the stack-size limit. Do a
unlimit stacksize
and it will run. The reason it works on 4.0 (and even with moving
the executable backwards) is that the stack expansion code and
other compiler support on 4.0 does the right thing even on the 3.2
system. Not a bug, rather a feature.
Burkhard Neidecker-Lutz
EUROMEDIA - Distributed Multimedia Archives for Cooperative TV Production
CEC Karlsruhe , European Applied Research Center, Digital Equip. Corp.
email: neideck@kar.dec.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1997-04-07 4:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-04-04 5:00 segmentation fault with a large array declaration Matthew Temple
1997-04-07 4:00 ` Burkhard Neidecker-Lutz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox