Mail Archives: djgpp/2001/03/27/23:04:07
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 -