Matlab R2017b – the MATLABWindow issue

I almost forgot, while discussing libpam last time, that the top reason for Matlab R2017b crashing in flames and destruction on Slackware 14.2 is actually MATLABWindow (and the Chromium underneath) that are causing problems. Solution? As always, cheat with libraries.

First of all, it is not always obvious what’s happening. If you see something like this after a nice, fresh install of Matlab:

>> appdesigner
Error using appdesservices.internal.browser.WebWindowController/startBrowser (line 87)
Unable to start App Designer due to an internal error.

 MATLABWindow application failed to launch. Unable to launch the MATLABWindow application

Error in appdesservices.internal.browser.AbstractBrowserController (line 47)
            obj.startBrowser(browserOptionsStruct);

Error in appdesservices.internal.browser.WebWindowController (line 23)
            obj = obj@appdesservices.internal.browser.AbstractBrowserController(varargin{:});

Error in appdesservices.internal.peermodel.BrowserControllerFactory/launchWebwindow (line 81)
            browserController = appdesservices.internal.browser.WebWindowController(varargin{:});

Error in appdesservices.internal.peermodel.BrowserControllerFactory/launch (line 73)
            browserController = obj.CallbackMethod(varargin{:});

Error in appdesigner.internal.application.AppDesignerWindowController/startBrowser (line 90)
                obj.BrowserController = obj.BrowserControllerFactory.launch(initialBrowserState);

Error in appdesigner.internal.application.AppDesignEnvironment/startAppDesigner (line 104)
                obj.AppDesignerWindowController.startBrowser(inputArguments{:});

Error in appdesigner (line 69)
    appDesignEvironment.startAppDesigner();
 
>> 

This means that the MATLABWindow crashed. To try it alone you can launch it from any bash terminal, it’s a native linux executable:

bash-4.3$ /usr/local/MATLAB/R2017b/bin/glnxa64/MATLABWindow 
/usr/local/MATLAB/R2017b/bin/glnxa64/MATLABWindow: symbol lookup error: /usr/lib64/../lib64/libgio-2.0.so.0: undefined symbol: g_option_group_unref

(you can try it also from Matlab, using ! to launch sys command:)

>> ! /usr/local/MATLAB/R2017b/bin/glnxa64/MATLABWindow

libgio-2.0 is from glib2, this missing dependency actually can be traced using:

bash-4.3$ ldd /usr/local/MATLAB/R2017b/bin/glnxa64/MATLABWindow | grep libgio
        libgio-2.0.so.0 => /usr/lib64/../lib64/libgio-2.0.so.0 (0x00007fd82ab68000)
bash-4.3$ ldd /usr/local/MATLAB/R2017b/bin/glnxa64/MATLABWindow | grep libglib2
        libglib-2.0.so.0 => /usr/local/MATLAB/R2017b/bin/glnxa64/../../cefclient/sys/os/glnxa64/libglib-2.0.so.0 (0x00007fd832cc9000)

So the problem is that most part of glib2 are local and reside in (matlabroot)/cefclient/sys/os/glnxa64/ (that’s the chromium’s cefclient directory) but not libgio – now you have two choices, the wrong one being:
preload the libgio-2.0 at the start of the Matlab with a local version:

LD_PRELOAD="/usr/local/MATLAB/R2017b/cefclient/sys/os/glnxa64/libgio-2.0.so" /usr/local/MATLAB/R2017b/bin/matlab

But this causes a problem with libffi and the lack of libselinux.so.0 – the first one is again with cefclient, the second – if you have Steam or anything like that just grab the supplied copy:

bash-4.3# locate libselinux
/home/anil/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/lib/x86_64-linux-gnu/libselinux.so.1
...
bash-4.3# cp /home/anil/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/lib/x86_64-linux-gnu/libselinux.so.1 /usr/local/MATLAB/R2017b/bin/glnxa64/

and finally preload both libgio-2.0 and libffi:

LD_PRELOAD="/usr/local/MATLAB/R2017b/cefclient/sys/os/glnxa64/libgio-2.0.so /usr/local/MATLAB/R2017b/cefclient/sys/os/glnxa64/libffi.so.5" /usr/local/MATLAB/R2017b/bin/matlab

Didn’t I mention it’s a wrong way? The fact that cefclient is shipped with its own glib2 hurts a bit, so the second (and actually working) option is to remove it:

bash-4.3$ cd /usr/local/MATLAB/R2017b/cefclient/sys/os/glnxa64
bash-4.3$ mkdir out
bash-4.3$ mv libglib* out/

and it should start using the glib2 shipped with Slackware. The great test:

bash-4.3$ /usr/local/MATLAB/R2017b/bin/glnxa64/MATLABWindow 
[0125/073833:ERROR:browser_main_loop.cc(231)] Running without the SUID sandbox! See https://chromium.googlesource.com/chromium/src/+/master/docs/linux_suid_sandbox_development.md for more information on developing with the sandbox on.
Fontconfig warning: "/etc/fonts/conf.d/50-user.conf", line 14: reading configurations from ~/.fonts.conf is deprecated. please move it to /home/anil/.config/fontconfig/fonts.conf manually
[0125/073833:WARNING:cefclient_gtk.cpp(48)] X error received: type 0, serial 316, error_code 8, request_code 42, minor_code 0

[0125/073834:INFO:client_handler.cpp(147)]  OnBeforeResourceLoad http://www.mathworks.com/

[0125/073834:INFO:client_handler.cpp(147)]  OnBeforeResourceLoad https://www.mathworks.com/

[0125/073834:INFO:client_handler.cpp(159)]  OnResourceResponse https://www.mathworks.com/

[0125/073834:INFO:client_handler.cpp(487)]  OnLoadStart 

[0125/073837:INFO:client_handler.cpp(516)]  OnLoadEnd 

and a nice picture like that:

Leave a Reply