[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: db mess



On Sat, Jun 05, 1999 at 05:38:33PM +0200, Marcus Brinkmann wrote:
> 
> * mandb segfaults when trying to build the index cache.

To follow up on this. It seems that something is broken but I don't know
what. Here is a simple program to reproduce the bug. Compile with "-ldb2".
You would need the db2 package (it compiles cleanly). Also, I attach a log
with a gdb session. I can't make any sense out of it. Can you?

If you leave out O_TRUNC, it will proceed and segfault later. All very
strange.

Thanks,
Marcus

-- 
`Rhubarb is no Egyptian god.' Debian http://www.debian.org   finger brinkmd@ 
Marcus Brinkmann              GNU    http://www.gnu.org     master.debian.org
Marcus.Brinkmann@ruhr-uni-bochum.de                        for public  PGP Key
http://homepage.ruhr-uni-bochum.de/Marcus.Brinkmann/       PGP Key ID 36E7CD09
#include <db2/db_185.h>
#include <errno.h>
#include <string.h>
#include <stdio.h>
#include <sys/file.h> /* for flock() */
#include <sys/types.h> /* for open() */
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

/* open a btree type database, with file locking. */
DB *btree_flopen(char *filename, int flags, int mode)
{
	DB *dbf;
	BTREEINFO b;
	int lock_op;
	int lock_failed;
	b.flags = 0; /* R_DUP */	

	b.cachesize = 0;	/* default size */
	b.maxkeypage = 0;	/* default */
	b.minkeypage = 0;	/* default */
	b.psize = 0;		/* default page size (2048?) */
	b.compare = NULL;	/* builtin compare() function */
	b.prefix = NULL;	/* builtin function */
	b.lorder = 0;		/* byte order of host */
	

       	dbf = NULL;
	lock_failed = 1;

	dbf = dbopen(filename, flags, mode, DB_BTREE, &b);

	return dbf;
}

main()
{
  printf ("%p\n",btree_flopen("/tmp/index",O_CREAT|O_RDWR|O_TRUNC, 0644));
  printf ("%s\n", strerror(errno));
}
 
Script started on Sun Jun  6 00:17:26 1999
hurd:/testdb# gdb ./aha
GNU gdb 4.17.m68k.objc.threads.hwwp.fpu.gnat
Copyright 1998 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-gnu"...
(gdb) brak main
Undefined command: "brak".  Try "help".
(gdb) break main
Breakpoint 1 at 0x804a187: file aha.c, line 39.
(gdb) run
Starting program: /testdb/./aha 
[Switching to thread 98.3]
[Switching to thread 98.5]

Breakpoint 1, main () at aha.c:39
39        printf ("%p\n",btree_flopen("/tmp/index",O_CREAT|O_RDWR|O_TRUNC, 0644));
(gdb) s
btree_flopen (filename=0x8090864 "/tmp/index", flags=65555, mode=420)
    at aha.c:18
18              b.flags = 0; /* R_DUP */        
(gdb) 
20              b.cachesize = 0;        /* default size */
(gdb) 
21              b.maxkeypage = 0;       /* default */
(gdb) 
22              b.minkeypage = 0;       /* default */
(gdb) 
23              b.psize = 0;            /* default page size (2048?) */
(gdb) 
24              b.compare = NULL;       /* builtin compare() function */
(gdb) 
25              b.prefix = NULL;        /* builtin function */
(gdb) 
26              b.lorder = 0;           /* byte order of host */
(gdb) 
29              dbf = NULL;
(gdb) 
30              lock_failed = 1;
(gdb) 
32              dbf = dbopen(filename, flags, mode, DB_BTREE, &b);
(gdb) 
dbopen (file=0x8090864 "/tmp/index", oflags=65555, mode=420, type=0, 
    openinfo=0x1019bc0) at /usr/src/db-2.4.14/db185/db185.c:54
54              if ((db185p = (DB185 *)__db_calloc(1, sizeof(DB185))) == NULL)
(gdb) 
__db_calloc (num=1, size=40) at /usr/src/db-2.4.14/os/os_alloc.c:68
68              size *= num;
(gdb) 
69              if ((p = __db_jump.j_malloc(size == 0 ? 1 : size)) != NULL)
(gdb) print __db_jump.j_malloc
$1 = (void *(*)()) 0x8049d94 <malloc>
(gdb) s
(nil)
Invalid argument

Program exited with code 021.
(gdb) 
Script done on Sun Jun  6 00:17:56 1999

Reply to: