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)

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)

Error in appdesigner (line 69)

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/ 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 => /usr/lib64/../lib64/ (0x00007fd82ab68000)
bash-4.3$ ldd /usr/local/MATLAB/R2017b/bin/glnxa64/MATLABWindow | grep libglib2 => /usr/local/MATLAB/R2017b/bin/glnxa64/../../cefclient/sys/os/glnxa64/ (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/" /usr/local/MATLAB/R2017b/bin/matlab

But this causes a problem with libffi and the lack of – 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
bash-4.3# cp /home/anil/.local/share/Steam/ubuntu12_32/steam-runtime/amd64/lib/x86_64-linux-gnu/ /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/ /usr/local/MATLAB/R2017b/cefclient/sys/os/glnxa64/" /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/] Running without the SUID sandbox! See 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

[0125/073834:INFO:client_handler.cpp(147)]  OnBeforeResourceLoad

[0125/073834:INFO:client_handler.cpp(159)]  OnResourceResponse

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

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

and a nice picture like that: