From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,92b5d9a11faac017,start X-Google-Attributes: gidfee84,public From: Matthew Temple Subject: segmentation fault with a large array declaration Date: 1997/04/04 Message-ID: <33454134.B80DDF0@compfac.tch.harvard.edu>#1/1 X-Deja-AN: 230847080 Organization: Harvard University University Information Systems Newsgroups: comp.unix.osf.osf1 Given the following program fragment: #include 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