*BSD News Article 49451


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!simtel!news.sprintlink.net!matlock.mindspring.com!usenet
From: Robert Sanders <rsanders@mindspring.com>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Bug in 2.0.5's dlopen() functionality
Date: 27 Aug 1995 15:39:08 -0400
Organization: MindSpring Enterprises, Inc.
Lines: 38
Sender: rsanders@hrothgar.mindspring.com
Message-ID: <87pwhri1b7.fsf@hrothgar.mindspring.com>
NNTP-Posting-Host: hrothgar.mindspring.com
X-Newsreader: (ding) Gnus v0.99.11

I'm using a mostly stock 2.0.5 setup with a couple of 2.1-stable
kernel fixes.

While working with Python 1.3, I decided to make some of the extension
modules dynamically loaded to reduce clutter in the main executable.
Everything seemed to work fine until I needed to load one that
depended on other shared libraries not used by the main executable.
That is:

$ ldd python
python:
	-lm.2 => /usr/lib/libm.so.2.0 (0x8160000)
	-lc.2 => /usr/lib/libc.so.2.1 (0x8178000)

ldd doesn't work on non-executable .so files, but here's how I created
the .so file:

$ make tkintermodule.so
ld -Bshareable  tkintermodule.o  -L/usr/X11R6/lib -L/usr/local/lib \
   -ltk40 -ltcl74 -lX11 -o tkintermodule.so

When I load tkintermodule.so into the python executable with dlopen(),
ktrace shows that the tk40, tcl74, and X11 libraries are at least
opened and mapped.  The call to a tkintermodule procedure works, but
that procedure doesn't use any code from the TCL/Tk/X11 libraries.
When I call a tkintermodule procedure that calls TCL/Tk/X11
procedures, the program crashes.  So, it seems that something doesn't
work quite right with "chained" dynamic linking.

If I make this one change, everything works: when linking the python
executable, simply specify "-ltcl74 -ltk -lX11" on the command line.

I don't have a simple test case for this, but could probably put one
together upon request.  I can also provide all the files used in this
example.

Regards,
  -- Robert