Subject: segmentation fault on fclose?
To: None <current-users@netbsd.org>
From: Andrew Gillham <gillham@andrews.edu>
List: current-users
Date: 09/04/1994 23:36:43
Just two questions...  Should the following code cause
a segmentation fault?  It doesn't on SunOS and Solaris, but
it does on my NetBSD v1.0_beta..
I admit that I am not much of a code hacker, so these may be
*real* obvious screwups..  In case anyone is curious, I'm trying
to get the 'mSQL' SQL database working under NetBSD..

The offensive code:

#include <stdio.h>

main()
{
FILE *fp;
fp = NULL;
fclose(fp);
}


Also, I am getting a segmentation fault like this:

Program received signal SIGSEGV (11), Segmentation fault
0x6a41 in readKey (key=0x90580) at msqldb.c:1094
1094    {
(gdb) where
#0  0x6a41 in readKey (key=0x90580) at msqldb.c:1094
#1  0x91b6 in msqlInsert (table=0x9c050 "test", fields=0xa4080, 
    DB=0x9c010 "bench") at msqldb.c:2630
#2  0x524b in msqlProcessQuery () at msql_proc.c:436
#3  0x28a5 in yyparse () at msql_yacc.y:89
#4  0x9cdc in msqlParseQuery (
    inBuf=0x9d040 "insert into test (name,num) values ('item 0', 0) \n", 
    sock=5) at msql_io.c:51
#5  0x231e in main (argc=1, argv=0xf7bfdbcc) at msqld.c:388
(gdb) 

Here's the code:

(gdb) list
1089    }
1090    
1091    #endif
1092    
1093    u_int readKey(keyDef *key)
1094    {
1095            int     numBytes,
1096                    maxRead,
1097                    fd;
1098            register int    rowLen,
(gdb)

In this case, the "key" data appears to be ok, it's as if
the stack is getting trashed or something.  Basically I haven't
got a clue... :-)

Any help, flames, etc would be appreciated... :-)

-Andrew

------------------------------------------------------------------------------