This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

nss crash in "make check"



glibc-2000-05-05 make check gives an error for me. It occurs during the
program nss/test-netdb and gives a backtrace as follows:

Program received signal SIGSEGV, Segmentation fault.
0x401399c0 in lookup (key=0xbffff434, result=0x40116348, buffer=0x804dd30, 
    buflen=1024, errnop=0x40114140) at nss_files/../nss_db/db-XXX.c:122
122       err = DL_CALL_FCT (db->get, (db->db, NULL, key, &value, 0));
(gdb) print db
$2 = (NSS_DB *) 0x0
(gdb) where
#0  0x401399c0 in lookup (key=0xbffff434, result=0x40116348, buffer=0x804dd30, 
    buflen=1024, errnop=0x40114140) at nss_files/../nss_db/db-XXX.c:122
#1  0x40139c1b in _nss_db_getprotobyname_r (name=0x8049b0d "IP", 
    result=0x40116348, buffer=0x804dd30 "", buflen=1024, errnop=0x40114140)
    at nss_files/files-proto.c:40
#2  0x400e7bc1 in __getprotobyname_r (name=0x8049b0d "IP", resbuf=0x40116348, 
    buffer=0x804dd30 "", buflen=1024, result=0xbffff4f8)
    at ../nss/getXXbyYY_r.c:189
#3  0x400e7a51 in getprotobyname (name=0x8049b0d "IP")
    at ../nss/getXXbyYY.c:141
#4  0x8049254 in test_protocols () at test-netdb.c:276
#5  0x8049445 in main () at test-netdb.c:360

How can 'db' be NULL at line nss_db/db-XXX.c:122 ? Only if
   internal_setent (DBFILE, &db)
returns NSS_STATUS_SUCCESS without setting 'db' to a non-NULL value. This
can happen in two ways, and both are bugs, I think:

a) see nss/nss_db/dp-open.c:187
   if load_db() returns a non-0 value. Indeed: load_db() can return 1,
   and the following "return status;" statement converts the 1 to
   NSS_STATUS_SUCCESS.

b) see nss/nss_db/dp-open.c:195
   if dbopen() returns NSS_STATUS_SUCCESS without setting '*dbp' to a non-NULL
   value. Indeed: this can happen, if the malloc() in the middle of dbopen
   returns NULL.

The following patch - for a) only - fixed it for me.


2000-05-06  Bruno Haible  <haible@clisp.cons.org>

	* nss/nss_db/db-open.c (internal_setent): When load_db() failed,
	return NSS_STATUS_UNAVAIL instead of NSS_STATUS_SUCCESS.

*** nss/nss_db/db-open.c.bak	Sat May  6 13:24:52 2000
--- nss/nss_db/db-open.c	Sat May  6 13:14:39 2000
***************
*** 189,195 ****
  	  __libc_lock_unlock (lock);
  
  	  if (status != 0)
! 	    return status;
  	}
  
        status = dbopen (file, db_rdonly, 0, dbp);
--- 189,195 ----
  	  __libc_lock_unlock (lock);
  
  	  if (status != 0)
! 	    return NSS_STATUS_UNAVAIL;
  	}
  
        status = dbopen (file, db_rdonly, 0, dbp);

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]