ctypes.cdll.LoadLibrary() freezes when loading a .so that contains dlopen()

Russell russell at infiniteio.com
Fri Feb 13 10:39:05 EST 2015


I have a shared library, libfoo.so, that references another .so which isn't linked but instead loaded at runtime with myso=dlopen("/usr/local/lib/libbar.so", RTLD_NOW); when I try to load it with ctypes, the call hangs and I have to ctl-c.

(build)[dev]$ export LD_LIBRARY_PATH=/usr/local/bin
(build)[dev]$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> ctypes.cdll.LoadLibrary ('/usr/local/lib/libfoo.so')   <--- This call hangs and have to ctl-C
^CTraceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
   return self._dlltype(name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
    self._handle = _dlopen(self._name, mode)
KeyboardInterrupt
>>>


My first thought was that It couldn't find libbar.so, but if I remove that file, python seg faults: /usr/local/lib/libbar.so: cannot open shared object file: No such file or directorySegmentation fault (core dumped), so it appears that it finds the dlopen() file but freezes waiting for ???

This is on ubuntu 14.4 server. C code is compiled with -std=gnu11 -Wall -Werror -m64 -march=x86-64 -mavx -g -fPIC

I also get the same reaction on python3.4

Thanks in advance



More information about the Python-list mailing list