From owner-freebsd-hackers Wed Apr 10 17:23: 4 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from swan.prod.itd.earthlink.net (swan.mail.pas.earthlink.net [207.217.120.123]) by hub.freebsd.org (Postfix) with ESMTP id DEEEC37B416 for ; Wed, 10 Apr 2002 17:22:50 -0700 (PDT) Received: from pool0071.cvx40-bradley.dialup.earthlink.net ([216.244.42.71] helo=mindspring.com) by swan.prod.itd.earthlink.net with esmtp (Exim 3.33 #1) id 16vSMO-0001eL-00; Wed, 10 Apr 2002 17:22:44 -0700 Message-ID: <3CB4D739.3F0E12D8@mindspring.com> Date: Wed, 10 Apr 2002 17:22:17 -0700 From: Terry Lambert X-Mailer: Mozilla 4.7 [en]C-CCK-MCD {Sony} (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: bruno@tinkerbox.org Cc: hackers@freebsd.org Subject: Re: problems with shared libraries References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG bruno@tinkerbox.org wrote: > I tried that and resolved all entry points. It is neither dlopen() nor > dlsym() that fail, it is when I try using that entry point that it fails. > > code snippet: > > if ((phandle = dlopen(filename, RTLD_LAZY)) == NULL) { Change this to "RTLD_NOW". > /* failed to load input plug */ > event_printf(EVENT_LOG, 0, "dlopen: %s.", dlerror()); > return(-1); > } Add: else printf( "dlopen failed: %s\n", dlerror()); > if ((gpi = dlsym(phandle, "get_iplugin_info")) != NULL) { > /* initialise as an input plugin */ > fails here----> ip = (InputPlugin *) gpi(); This can only happen if the "get_iplugin_info" function in your module references symbols defined in a shared object not loaded before it was loaded. Use "nm foo.So" for the shared object for the module "foo.so" to see what external suymbols are referenced by the module. > the backtrace shows that calling get_iplugin_info() leads to a > g_strdup_printf() that later fails in vfprintf() from libc_r.so.4 > > so it fails in a call to glib. You'll tell me there is a bug in the > plugin, but I know there is not, this plugin (shared lib) works perfectly > with xmms. Ah. You are using glib. That's implicitly broken. Don't use glib, and your problem will go away. > Which leads me to thinking there is a problem between differing libs, or > something. Any other ideas ? Create a module "wrapper.so" that dlopen's glib.so.xxx, and *then* dlopen's your module, and then reflects the interfaces down. Alternately, don't use glib: it's intrinsically broken, by design. -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message