7

It seems like MATLAB is royally screwed up on Linux, because it "dynamically loads some libs with static TLS", which doesn't mean anything to me other than I get bunches of errors.

The suggested work around is to rebuild glibc with a larger DTV_SURPLUS. This leaves me with two questions:

  • How do I rebuild glibc on Arch Linux to increase the DTV_SURPLUS? I looked at the PKGBUILD in the abs tree and didn't see DTV_SURPLUS anywhere, so I don't know where to make the change.
  • What value do I set DTV_SURPLUS to be? Presumably, setting it to 2^64 would both be overkill and a bad idea.

The issue with MATLAB can be seen with the following MWE in R2014a:

>> ones(10)*ones(10);
>> doc('help');
Exception in thread "XPCOMMessageLoop" java.lang.UnsatisfiedLinkError: /opt/matlab/sys/jxbrowser/glnxa64/xulrunner/xulrunner-linux-64/libxul.so: dlopen: cannot load any more object with static TLS
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(Unknown Source)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.impl.linux.LinuxMozillaToolkit.c(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.impl.linux.LinuxMozillaToolkit.a(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.MozillaToolkit.initialize(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.AppShellXPCOMThread$b.run(Unknown Source)
Exception in thread "XPCOMMessageLoop" java.lang.UnsatisfiedLinkError: /opt/matlab/sys/jxbrowser/glnxa64/xulrunner/xulrunner-linux-64/libxul.so: dlopen: cannot load any more object with static TLS
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(Unknown Source)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.impl.linux.LinuxMozillaToolkit.c(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.impl.linux.LinuxMozillaToolkit.a(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.MozillaToolkit.initialize(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.AppShellXPCOMThread$b.run(Unknown Source)
Exception in thread "XPCOMMessageLoop" java.lang.UnsatisfiedLinkError: /opt/matlab/sys/jxbrowser/glnxa64/xulrunner/xulrunner-linux-64/libxul.so: dlopen: cannot load any more object with static TLS
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(Unknown Source)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.impl.linux.LinuxMozillaToolkit.c(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.impl.linux.LinuxMozillaToolkit.a(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.MozillaToolkit.initialize(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.AppShellXPCOMThread$b.run(Unknown Source)
Exception in thread "XPCOMMessageLoop" java.lang.UnsatisfiedLinkError: /opt/matlab/sys/jxbrowser/glnxa64/xulrunner/xulrunner-linux-64/libxul.so: dlopen: cannot load any more object with static TLS
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(Unknown Source)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.impl.linux.LinuxMozillaToolkit.c(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.impl.linux.LinuxMozillaToolkit.a(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.MozillaToolkit.initialize(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.AppShellXPCOMThread$b.run(Unknown Source)
Exception in thread "XPCOMMessageLoop" java.lang.UnsatisfiedLinkError: /opt/matlab/sys/jxbrowser/glnxa64/xulrunner/xulrunner-linux-64/libxul.so: dlopen: cannot load any more object with static TLS
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary1(Unknown Source)
    at java.lang.ClassLoader.loadLibrary0(Unknown Source)
    at java.lang.ClassLoader.loadLibrary(Unknown Source)
    at java.lang.Runtime.load0(Unknown Source)
    at java.lang.System.load(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.impl.linux.LinuxMozillaToolkit.c(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.impl.linux.LinuxMozillaToolkit.a(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.MozillaToolkit.initialize(Unknown Source)
    at com.teamdev.jxbrowser.gecko.xpcom.AppShellXPCOMThread$b.run(Unknown Source)

Where ones(10)*ones(10); loads the dynamically linked libiomp5.so BLAS library, which seems to not leave enough space for the dynamically linked libxul.so required for the HTML based documentation browser. Potentially I can work around this particular MWE by using a patched version of libiomp5.so, but the general problem still persists.

5
  • You'd probably be better off checking around to see if there's a distro that has glibc already compiled with a higher DTV_SURPLUS -- perhaps by testing in a VM.
    – goldilocks
    Jul 8, 2014 at 13:16
  • @goldilocks would a chroot be enough or do I need a full VM?
    – StrongBad
    Jul 8, 2014 at 13:21
  • I found this : stackoverflow.com/questions/19268293/… and this : mathworks.com/matlabcentral/answers/… . A Google search after "cannot load any more object with static TLS" is bound to give you more ideas.
    – schaiba
    Jul 8, 2014 at 13:21
  • I linked to the SO question in my question and that is where the idea of rebuilding glibc was suggested.
    – StrongBad
    Jul 8, 2014 at 13:24
  • The kernel's not an issue so you could use chroot.
    – goldilocks
    Jul 8, 2014 at 13:28

1 Answer 1

2

To recompile glibc with custom DTV_SURPLUS and override the existing version:

  1. Copy /var/abs/core/glibc to another directory so you can write to it without being root, then cd to that directory.
  2. Use makepkg -o to download and extract the source code without building it(because we will edit the source code before building).
  3. Edit DTV_SURPLUS located in src/glibc-<version>/sysdeps/generic/ldsodefs.h. You may just change the number in the line containing DTV_SURPLUS.
  4. Build it with makepkg -e.
  5. Install the custom version with sudo pacman -U <package file>. This will override the official package previously installed.

If you don't want to override the existing version, you can use chroot, or maybe LD_PRELOAD will also work.

However, I'm unsure what should DTV_SURPLUS be.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .