Message-ID: <3AC1609C.A537E890@earthlink.net> From: Martin Ambuhl X-Mailer: Mozilla 4.76 [en] (Win95; U) X-Accept-Language: en,zh-CN,fr,de-CH,ru MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: Hunting Sigsev Errors References: <3ac02f4b$0$14446$272ea4a1 AT news DOT execpc DOT com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 57 Date: Wed, 28 Mar 2001 03:51:50 GMT NNTP-Posting-Host: 64.152.166.233 X-Complaints-To: abuse AT earthlink DOT net X-Trace: newsread1.prod.itd.earthlink.net 985751510 64.152.166.233 (Tue, 27 Mar 2001 19:51:50 PST) NNTP-Posting-Date: Tue, 27 Mar 2001 19:51:50 PST Organization: EarthLink Inc. -- http://www.EarthLink.net 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: [compileable version with results below] > > This code fragment will ALWAYS generate a SIGSEV before the LOG call. If it > doesn't - I get real strange behavior out of the fread() function call. > Changing the ARRAYSIZE to 512 fixes this - no more SIGSEV and no more wierd > behavior out of fread(). Looks like some sort of allocation bug or internal > limit is being reached (1024x516= ~.5M, but 512x516=~.25M). > > NOTE: The rest of the above program is another 50 lines of C code - that's > all - no subroutines, etc. Just a main() module. I cannot reproduce your error: #include #include #define LOG(a,b) fprintf(stderr, a, b); #define ARRAYMAX 1024 #define NUL (char)0 int main(int argc, char *argv[]) { FILE *ifp, *ofp; int i, p; char *pos, *j; struct hdr { char cbs[4]; long start; long last; } cbs_hdr; struct rec { long index; char fname[512]; } allrecs[ARRAYMAX]; LOG("Starting with argc = %d\n", argc); return 0; } $gcc -O3 -W -Wall -ansi -pedantic a.c 2>a.e $gcc -v Reading specs from c:/djgpp/lib/gcc-lib/djgpp/2.953/specs gcc version 2.95.3 20010315/djgpp (release) $./a Starting with argc = 1 $./a foo Starting with argc = 2 $./a foo bar Starting with argc = 3