From: "Greg Donnells" Newsgroups: comp.os.msdos.djgpp References: <3ac02f4b$0$14446$272ea4a1 AT news DOT execpc DOT com> <3AC1609C DOT A537E890 AT earthlink DOT net> Subject: Re: Hunting Sigsev Errors Lines: 202 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2919.6600 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Message-ID: Date: Wed, 28 Mar 2001 14:49:56 GMT NNTP-Posting-Host: 24.164.23.148 X-Complaints-To: abuse AT rr DOT com X-Trace: typhoon.tampabay.rr.com 985790996 24.164.23.148 (Wed, 28 Mar 2001 09:49:56 EST) NNTP-Posting-Date: Wed, 28 Mar 2001 09:49:56 EST Organization: RoadRunner - TampaBay To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Here is the source code (full, since this problem does not manifest itself in a smaller program that uses the same structures) - after the code you'll find the complier output - after the complier output, you'll find the runtime output.... Note that if you change the ARRAYSIZE to 512 (instead of 1024) that all problems go away. ------------------------------- gcc version ------------------------------- Reading specs from c:/cc/lib/gcc-lib/djgpp/2.953/specs gcc version 2.95.3 20010315/djgpp (release) ------------------------------- source code - dumpcbs.c ------------------------------- /* ** dumpcbs.c ** ** dumps cbs files from filename $1 - writes to fname $2 ** ** Usage: dumpcbs ** */ #include #include #define LOG(a,b) fprintf(stderr, a, b); /* #define LOG(a, b) /* null */ #define ARRAYMAX 1024 #define NUL (char)0 void main (int argc, char *argv[]) { FILE *ifp, *ofp; int i; char *pos; /* ** header structure */ struct hdr { char cbs[4]; long start; long last; } cbs_hdr; /* ** record structure ** make it an array so we can read the whole thing in and ** determine the number of files in the CBS file before ** writing them out */ struct rec { long index; char fname[512]; } allrecs[ARRAYMAX]; LOG("Starting: argc is %d\n", argc) if (argc != 3) { fprintf(stderr, "\nUsage: %s \n\n", argv[0]); exit(1); } /* ** open input .cbs file */ LOG("opening '%s' for read\n", argv[1]) if ((ifp=fopen(argv[1],"rb"))==NULL) { fprintf(stderr, "\nError -2: Could not open '%s' for reading.\n\n", argv[1]); exit(-2); } /* ** open output file */ LOG("opening '%s' for write\n", argv[2]) if ((ofp=fopen(argv[2],"wb"))==NULL) { fprintf(stderr, "\nError -2: Could not open '%s' for writing.\n\n", argv[2]); exit(-2); } /* ** read header */ LOG("Reading header size: %d\n", sizeof(struct hdr)) if (fread(&cbs_hdr, sizeof(struct hdr), 1, ifp)!=1) { fprintf(stderr,"\nError %d: input file header read error\n\n", -3); exit(-3); } LOG("...header is: %s\n", cbs_hdr.cbs); LOG("...start is: %d\n", cbs_hdr.start); LOG("...last is: %d\n", cbs_hdr.last); /* ** read all records in infile into structures */ /* for(i=0;i