director icon indicating copy to clipboard operation
director copied to clipboard

ImportError: dlopen: cannot load any more object with static TLS

Open patmarion opened this issue 8 years ago • 0 comments

On some machines, such as Ubuntu 14.04, importing python modules can trigger an error that looks like:

import pydrake.solvers.ik as pydrakeik
  File "/home/ubuntu/workspace/linux-clang-experimental-debug/build/install/lib/python2.7/dist-packages/pydrake/solvers/ik.py", line 5, in <module>
    from ._pydrake_ik import (IKResults,
ImportError: dlopen: cannot load any more object with static TLS

The issue appears to be associated with dynamically loading a library (or a library with dependencies) that has the STATIC_TLS flag. For example, the above import error might be associated with libiomp5.so. You can check the STATIC_TLS flag like this:

readelf --dynamics <.so filename> | grep TLS

A workaround is to import that module before any other module. Or, you can try setting the LD_PRELOAD environment variable to the path to the problem library (libiomp5.so, for example). For the case of libiomp5.so, I found that the system version of the library worked, while the version provided by the mosek solver did not.

Further reading:

http://stackoverflow.com/questions/19268293/matlab-error-cannot-open-with-static-tls

http://stackoverflow.com/questions/14892101/cannot-load-any-more-object-with-static-tls

http://stackoverflow.com/questions/13650740/dlopen-cannot-load-any-more-object-with-static-tls

patmarion avatar Feb 16 '17 18:02 patmarion