Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2007 21:34:33 +0100
From:      "Markus Hoenicka" <markus.hoenicka@mhoenicka.de>
To:        freebsd-questions@freebsd.org
Subject:   threading and dlopen()
Message-ID:  <18280.11993.211065.843394@yeti.mininet>

next in thread | raw e-mail | index | archive | help
Hi,

please bear with me if the issue below sounds familiar[1]. I've done some
more experiments to find out why the firebird client library crashes
on my box. If you're familiar with threads and dynamic linking, please
read on.

I'm trying to fix the libdbi driver for the firebird database engine
on FreeBSD. libdbi is a C library that your application can link
to. libdbi dlopen()s drivers which are shared objects themselves and
provide the specific code to talk to the database client
libraries. libdbi works across several platforms and supports a
variety of database engines - with the notable exception of firebird
on FreeBSD.

I can create and access firebird databases using the isql command line
tool. I can build and run a simple test program which creates a
firebird database, opens it, and closes it again. Now, if I use pretty
much the same code, compile it into a shared object, and dlopen() it,
the firebird client library invariably crashes with the following
gdb output:

#0  0x28535b36 in ThreadData::restoreSpecific() from /usr/local/lib/libfbclient.so.2
#1  0x2852ceb4 in return_success () from /usr/local/lib/libfbclient.so.2
#2  0x28525179 in REM_attach_database () from /usr/local/lib/libfbclient.so.2
#3  0x2851386a in isc_attach_database () from /usr/local/lib/libfbclient.so.2
#4  0x284ece8e in _dbd_real_connect ()
   from /usr/local/lib/dbd/libdbdfirebird.so
#5  0x284eba19 in dbd_connect () from /usr/local/lib/dbd/libdbdfirebird.so
#6  0x2808011d in dbi_conn_connect () from /usr/local/lib/libdbi.so.0
#7  0x0804982a in main (argc=1, argv=0xbfbfea2c) at test_dbi.c:91

My (limited) analysis makes me think this is some sort of a threading
issue aggravated by the fact that the code is dlopen()ed (remember the
same code works ok if compiled into a standalone app). BTW the
firebird client library is the only library supported by libdbi which
uses threads. All other drivers do not use threads and work ok.

The firebird driver works ok on a variety of other platforms,
including Linux and as weird ones as Windows. It somehow hurts my
pride that it fails on FreeBSD.

Does anyone out there have an idea how to fix this odd problem?

System is 6.1-RELEASE, firebird2-client 2.0.3_1 was built as a port,
libdbi and libdbi-drivers (both current cvs versions) were built from
the sources (not as ports).

regards,
Markus

[1] http://lists.freebsd.org/pipermail/freebsd-questions/2007-December/164571.html

-- 
Markus Hoenicka
markus.hoenicka@cats.de
(Spam-protected email: replace the quadrupeds with "mhoenicka")
http://www.mhoenicka.de




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?18280.11993.211065.843394>