A dynamic linking issue with bzr-svn and sqlite on MacOS X

Brian de Alwis bsd at cs.ubc.ca
Wed Sep 24 00:42:17 BST 2008


I'm posting this in case this problem bites anybody else.

I recently upgraded to bzr 1.6.1 and bzr-svn 0.4.12 on MacOSX 10.5.5  
to work with some Subversion-hosted repositories.  Attempting to use  
bzr-svn to access a subversion repository would spew out warning  
messages about freeing of non-aligned pointers and eventually fail  
with the following error:

   File "/usr/pkg/lib/python2.5/site-packages/bzrlib/plugins/svn/ 
repository.py", line 205, in __init__
     cachedbs[cache_file] =  
sqlite3.connect(cache_file.encode(osutils._fs_enc))
SystemError: NULL result without error in PyObject_Call

Tracing through with gdb, I finally twigged onto the fact that there  
were two sqlite3 dynamic libraries being loaded, and this was leading  
to some naughty interaction.

I use pkgsrc.org, which is similar to macports and fink; pkgsrc.org  
installs and uses its own copies of python 2.5 and libraries such as  
sqlite 3.0.8.6, etc., which are installed under /usr/pkg.  MacOS X  
also ships with an install of python 2.5 and many libraries, including  
sqlite 3.0.8.6, which are installed in /usr/{bin,lib,...}.  Loading  
bzrlib somehow leads to a 'gestalt' module being loaded on MacOS X,  
which loads some of the system DLLs.  MacOS X uses sqlite3 for many of  
its system databases, and one of these system DLLs leads to the  
system's /usr/lib/libsqlite3.0.8.6.dylib being loaded, while the  
pkgsrc's python's _sqlite3.so module loads /usr/pkg/lib/ 
libsqlite3.0.8.6.dylib.  For some reason, the dynamic linker appears  
to bind some of the exported symbols to the system library, and others  
to the pkgsrc library, and eventually leads to some bad interaction.

An immediate workaround for anybody else in this situation: cause the  
pkgsrc/macports/fink sqlite library to be loaded first using something  
like:

	$ DYLD_INSERT_LIBRARIES=/usr/pkg/lib/libsqlite3.0.8.6.dylib \
	   bzr ...

A somewhat nicer workaround is found in comment #9 on MacPorts ticket  
15131 <https://trac.macports.org/ticket/15131#comment:9> which  
replaces the _sqlite3.so module with one that links to the system  
library.

Brian.

-- 
  Brian de Alwis | Software Practices Lab | UBC | http://www.cs.ubc.ca/~bsd/
       "Amusement to an observing mind is study." - Benjamin Disraeli




More information about the bazaar mailing list