If anyone could help me out with the following, it would be much appreciated:

        I have compiled a relatively large C program with gcc (on a linux
486 machine) using: gcc prog.c -lgdbm

Part of the code defining some of the variables of one of the functions is
as follows:

        datum key;
        datum key1;
        datum key2;
        datum key3;
        datum content;
        datum content1;
        datum content2;
        datum content3;

where datum is defined in the gdbm.h include file as :
        struct{
                char *dptr;
                int dsize;
                } datum

However, the program constantly causes segmentation faults.  Examining the
program using gdb (after compiling with "gcc prog.c -lgdbm -ggdb") reveals
that key, key1, key2, key3, content, and content2 are all fine. ie. using
"display content" in gdb returns:
        content={dptr=0xbffffa7c "0", dsize = 1}        
  However, using "display content1" in gdb reveals:
                content1={dptr= 0x0, dsize =-1073743240}
and similarly for content3.  And the program causes the segementation fault
at the line which calls content1 for the first time.

>From experience programming on other operating systems which shall remain
anonymous, I figure I need to swtich to a larger memory model, or something
else to allow gcc to allocate memory to content1 and content3 but nothing in
the info, man, or other linux programming books tells me how to do this.  Of
course, this preliminary diagnosis could be entirely wrong...

I'm sorry for taking up so much bandwidth with this question, but the fact
that out of 8 identical variable declarations 6 were fine and 2 were not is
exceedingly puzzling -- normally things either always work or never work...

Thanks in advance for any help,

Berkeley Hynes
[EMAIL PROTECTED]

Reply via email to