delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/27/17:16:56

From: "Greg Donnells" <gad AT donnesys DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <3ac02f4b$0$14446$272ea4a1 AT news DOT execpc DOT com> <Um7w6.1128$eX4 DOT 241968 AT typhoon DOT tampabay DOT rr DOT com>
Subject: Re: Hunting Sigsev Errors
Lines: 41
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: <l48w6.369$083.262866@typhoon.tampabay.rr.com>
Date: Tue, 27 Mar 2001 22:00:49 GMT
NNTP-Posting-Host: 24.164.23.148
X-Complaints-To: abuse AT rr DOT com
X-Trace: typhoon.tampabay.rr.com 985730449 24.164.23.148 (Tue, 27 Mar 2001 17:00:49 EST)
NNTP-Posting-Date: Tue, 27 Mar 2001 17:00:49 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

Well, I've discovered something interesting regarding SIGSEV errors and gcc
(2.953). Consider the following code fragment:

-----------------------------------------------------
#include <stdio.h>
#include <string.h>

#define LOG(a,b) fprintf(stderr, a, b);
#define ARRAYMAX 1024
#define NUL (char)0

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);
-----------------------------------------------------

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.


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019