htdig: Berkeley DB 1.85 and malloc/free

Jesse op den Brouw (
Mon, 23 Mar 1998 13:10:10 +0100

Does anyone of you use Berkeley DB 1.85 in combination with malloc/free

If yes, then here is my problem:

I'm using the search engine htdig ( Standard,
htdig uses gdbm as its database engine/files. Esa Aloha redecorated
htdig for use with Berkeley DB 1.85 (on a FreeBSD system, he clames
it runs without problem on his machine). It has
some advantage over gdbm. I patched his code into htdig and it
compiled/linked perfectly, but when I run the digger it crashes with
the following, (from xxgdb, on a RH 5.0 system):

Program received signal SIGSEGV, Segmentation fault.
chunk_free () at malloc.c:2776
malloc.c:2776: No such file or directory.
Current language: auto; currently c

When I do a stack trace it gives me:

(xxgdb) info stack
#0 chunk_free () at malloc.c:2776
#1 0x400ac991 in __cfree () at malloc.c:2684
#2 0x8056d95 in DB_db::Get (this=0x806e350, key=@0xbffff71c,
data=@0xbffff72c) at
#3 0x8050186 in DocumentDB::operator[] (this=0x805a71c, u=0x8070a18
"http://localhost/manual/") at
#4 0x804d9d5 in Retriever::GetRef (this=0xbffff814, u=0x809cc20
"http://localhost/manual/") at
#5 0x804d193 in Retriever::parse_url (this=0xbffff814,
urlRef=@0x809dbb0) at
#6 0x804d121 in Retriever::Start (this=0xbffff814) at
#7 0x804f604 in main (ac=5, av=0xbffff998) at

Ok, so now for the locals...(xxgdb) info locals
ms = (struct malloc_state *) 0x80709cd
i = 1074785964
b = (struct malloc_chunk *) 0x80709d5

??? i = 10747..... Does this mean that free wants to free 1 GB??

Now, I looked at the code Esa wrote, but I couldn't find any strange

// int DB_db::Get(String &key, String &data)
DB_db::Get(String &key, String &data)
    DBT k, d;

    if (!isOpen)
        return NOTOK; = key.get();
    k.size = key.length();

    int rc = (dbf->get)(dbf, &k, &d, 0);
    if (rc)
        return NOTOK;

    data = 0;
    data.append((char *), d.size);

// note: it crashes on the following free()....
    return OK;

Is there a known problem with berkeley DB 1.85?
When linking, does it actualy link against Berkeley DB 1.85 or maybe
against Berkeley 2.x.x (there is a
Are the libdb.a or using the same malloc/free as the rest
of my program/

J. op den Brouw Johanna Westerdijkplein 75
Haagse Hogeschool 2521 EN DEN HAAG
Faculty of Engineering Netherlands
Electrical Engineering +31 70 4458936
-------------------- ---------------------

Linux - because reboots are for hardware changes
To unsubscribe from the htdig mailing list, send a message to containing the single word "unsubscribe" in
the body of the message.

This archive was generated by hypermail 2.0b3 on Sat Jan 02 1999 - 16:25:50 PST