delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/03/27/23:04:07

Message-ID: <3AC1609C.A537E890@earthlink.net>
From: Martin Ambuhl <mambuhl AT earthlink DOT net>
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> <Um7w6.1128$eX4 DOT 241968 AT typhoon DOT tampabay DOT rr DOT com> <l48w6.369$083 DOT 262866 AT typhoon DOT tampabay DOT rr DOT com>
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 <stdio.h>
#include <string.h>

#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

- Raw text -


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