Home Blog

MATLAB

I ran into several MATLAB startup and graphics failures on Arch across three releases. They looked similar at first, but the backtraces and library-loading errors pointed to different causes. These are the fixes that worked for my installations.

glibc 2.41 executable-stack bug

glibc 2.41 stopped honoring a library's request for an executable stack via dlopen/dlmopen. Some of MATLAB's bundled .so files ask for exactly that, so they segfault on load. Clear the flag with patchelf:

sudo patchelf --clear-execstack ~/.MathWorks/ServiceHost/-mw_shared_installs/v2025.1.1.2/bin/glnxa64/libmwfoundation_crash_handling.so
sudo patchelf --clear-execstack ~/.MathWorks/ServiceHost/-mw_shared_installs/v2025.1.1.2/bin/glnxa64/mathworksservicehost/rcf/matlabconnector/serviceprocess/rcf/service/libmwmshrcfservice.so

Check for executable-stack libraries before applying this fix. My R2026a installation had none; MathWorks had already corrected those libraries:

find "$MATLAB_ROOT" -name '*.so' -print0 \
  | xargs -0 -I{} sh -c 'readelf -lW "{}" | grep -q "GNU_STACK.*RWE" && echo {}'

gnutls ABI break (R2026a activation)

On a fresh R2026a installation, the process exited before the activation window appeared, without showing an error. The backtrace pointed to a different failure from the executable-stack issue:

gdb -q -batch -ex run -ex bt --args \
  "$MATLAB_ROOT/bin/glnxa64/MathWorksProductAuthorizer"

The crash occurs in libgnutls.so.30, called from lc_init() in libmwinstall_activationwsclientimpl.so. MATLAB’s activation and licensing plugin loads the system gnutls through dlopen() at runtime. The version installed on Arch was ABI-incompatible with what that client expected.

I built a private set of pinned gnutls and nettle libraries and added them to LD_LIBRARY_PATH for MATLAB. The versions need to match: gnutls 3.8.9-1 needs libhogweed to export nettle_rsa_oaep_sha384_decrypt under symbol version HOGWEED_6. nettle 3.9.1 lacks that symbol; 3.10-1 provides it under the same soname.

mkdir -p ~/.local/lib/matlab-gnutls-compat
cd /tmp && mkdir gnutls-old nettle-310

curl -sL -o gnutls-old/g.pkg.tar.zst \
  https://archive.archlinux.org/packages/g/gnutls/gnutls-3.8.9-1-x86_64.pkg.tar.zst
tar --zstd -xf gnutls-old/g.pkg.tar.zst -C gnutls-old

curl -sL -o nettle-310/n.pkg.tar.zst \
  https://archive.archlinux.org/packages/n/nettle/nettle-3.10-1-x86_64.pkg.tar.zst
tar --zstd -xf nettle-310/n.pkg.tar.zst -C nettle-310

cp -a gnutls-old/usr/lib/libgnutls* ~/.local/lib/matlab-gnutls-compat/
cp -a nettle-310/usr/lib/libnettle* nettle-310/usr/lib/libhogweed* \
  ~/.local/lib/matlab-gnutls-compat/

Then launch MATLAB with that on LD_LIBRARY_PATH:

env LD_LIBRARY_PATH=~/.local/lib/matlab-gnutls-compat \
  "$MATLAB_ROOT/bin/matlab" -nodesktop -nosplash -nosoftwareopengl

To pop the activation window on its own — e.g. to (re)activate without launching the full app — run the authorizer client directly with the same LD_LIBRARY_PATH:

env LD_LIBRARY_PATH=~/.local/lib/matlab-gnutls-compat \
  "$MATLAB_ROOT/bin/glnxa64/MathWorksProductAuthorizer.sh"

This workaround is specific to R2026a. R2026b starts with the system gnutls 3.8.13 and nettle 4.0, and with the pinned libraries on LD_LIBRARY_PATH it aborts with a heap error instead. Drop the variable from launchers when you upgrade.

Check shell configuration for old LD_PRELOAD workarounds after a MATLAB upgrade. In particular, LD_PRELOAD=/usr/lib/libstdc++.so has been documented as a separate cause of crashes. A leftover setting can obscure the failure you are trying to diagnose.

Segfault in lc_new_job (R2026b)

A fresh R2026b installation crashed on every start, before printing anything:

Segmentation violation
[  0] .../matlab_startup_plugins/lmgrimpl/libmwlmgrimpl.so  lc_new_job+00000216
...
[  9] .../libmwservices.so  MatlabLicensing::getInstance(...)

It looked like the gnutls crash above, since both sit in the licensing code. The pinned gnutls libraries made no difference, and no library had an executable stack. The cause was simpler: the installation had never been activated. There was no licenses/ directory under the MATLAB root and no ~/.matlab/R2026b_licenses. With nothing to check out, the FlexLM client dereferences a null job handle instead of reporting a missing license.

My older R2025b installation uses online (named-user) licensing, which needs only a marker file:

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<root>

  <ActivationEntry hostname="*" matlabroot="*" user="*">
    <licmode>onlinelicensing</licmode>
  </ActivationEntry>

</root>

Copying it into the new release fixed the crash:

mkdir -p "$MATLAB_ROOT/licenses"
cp /usr/local/MATLAB/R2025b/licenses/license_info.xml "$MATLAB_ROOT/licenses/"

Without an older installation to copy from, run $MATLAB_ROOT/bin/glnxa64/MathWorksProductAuthorizer.sh to activate. I did not need it this time, so I have not checked what it writes for R2026b. Look for licenses/ first whenever a new release crashes inside libmwlmgrimpl.so.

"Graphics acceleration hardware is unavailable" (R2026a)

I also had a graphics problem in R2026a. Figures now use WebGL inside embedded Chromium (MATLABWindow and libcef.so), through ANGLE, rather than desktop OpenGL. The software fallback is SwiftShader. On my Arch installation, MATLAB used it even though the GPU worked in other applications.

opengl('data') is gone in R2026a. The replacement is rendererinfo:

r = rendererinfo;
disp(r.RendererDevice)
disp(r.Details.HardwareSupportLevel)

On my Radeon 780M, with a working amdgpu and Mesa installation, it reported:

ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)

Root cause

ANGLE picks its Vulkan backend, asks the loader to enumerate devices, and the only ICD that answers is the SwiftShader one MATLAB ships (bin/glnxa64/vk_swiftshader_icd.json). The real driver never loads. Reproduce the failure directly, outside MATLAB, with a five-line dlopen harness:

#include <dlfcn.h>
#include <stdio.h>
int main(int c, char **v) {
  void *h = dlopen(v[1], RTLD_NOW);
  printf("%s\n", h ? "OK" : dlerror());
  return !h;
}
gcc -o dlopentest dlopentest.c
./dlopentest /usr/lib/libvulkan_radeon.so                      # OK
LD_LIBRARY_PATH=$MATLAB_ROOT/sys/os/glnxa64 \
  ./dlopentest /usr/lib/libvulkan_radeon.so
# .../sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.32' not found
#   (required by /usr/lib/libSPIRV-Tools.so)

The error identifies the library mismatch. radv links libSPIRV-Tools, which needs GLIBCXX_3.4.32 from the system toolchain. MATLAB loads its bundled libstdc++.so.6.0.30 from GCC 12.3 ahead of the system 6.0.36. As a result, radv cannot load, Vulkan enumeration finds only SwiftShader, and MATLAB falls back to software rendering.

Why LD_LIBRARY_PATH cannot fix this

I tried prepending a directory containing a symlink to the system libstdc++. MATLAB’s launcher also provides LDPATH_PREFIX, which places a directory at the front of LD_LIBRARY_PATH. Neither worked because the binary uses DT_RPATH:

readelf -d "$MATLAB_ROOT/bin/glnxa64/MATLABWindow" | grep -E 'RPATH|RUNPATH'
# 0x000000000000000f (RPATH) Library rpath: [$ORIGIN:$ORIGIN/../../sys/os/glnxa64]

The dynamic linker searches DT_RPATH before LD_LIBRARY_PATH. I checked the running process to see which library it had actually mapped:

grep -oE '/[^ ]*libstdc\+\+[^ ]*' /proc/$(pgrep -f MATLABWindow | head -1)/maps
# /usr/local/MATLAB/R2026a/sys/os/glnxa64/libstdc++.so.6.0.30

LD_PRELOAD loads the library early enough to take precedence over that RPATH.

Fix

env LD_PRELOAD=/usr/lib/libstdc++.so.6 "$MATLAB_ROOT/bin/matlab"

Newer libstdc++ keeps the old symbol versions, so MATLAB's own GCC-12-era libraries are satisfied by 6.0.36 too. The launcher appends to LD_PRELOAD (LD_PRELOAD="${LD_PRELOAD:+${LD_PRELOAD}:}...") instead of clobbering it, so an inherited value survives alongside MATLAB's own shims. Result:

ANGLE (AMD, AMD Radeon 780M Graphics (radeonsi phoenix ACO), OpenGL 4.6)
HardwareSupportLevel: Full

This uses the versioned libstdc++.so.6, rather than the libstdc++.so linker script mentioned in the activation section. I would still remove the preload first when diagnosing a later MATLAB failure, since a future release may no longer need it.

If you'd rather not carry the variable, MATLAB's bundled libstdc++.so.6 is already just a symlink and the pristine copies live in sys/os/glnxa64/orig/, so repointing it at /usr/lib/libstdc++.so.6 does the same thing install-wide, at the cost of a change a MATLAB update can quietly revert.

Other fixes I tried

I also found MW_ENABLE_GPU_RENDERING beside disable-gpu and enable-unsafe- swiftshader in libmwcef_common.so. Setting it made no difference: ANGLE could not load the driver. The bin/glnxa64/gpu_info tool reported the correct device (0x1002:0x1900) but a driver version of 0.0.0.0, so it did not explain the loading failure.

Also, -nosoftwareopengl is now inert: R2026a answers with Warning: OpenGL Startup options have been removed. Drop it from launcher aliases.

Verify

After checking rendererinfo, I rendered a figure with lighting and transparency to exercise the graphics path:

f = figure('Visible','off');
[X,Y,Z] = peaks(120);
surf(X,Y,Z,'EdgeColor','none'); camlight; lighting gouraud; alpha 0.7
exportgraphics(f, 'hwtest.png', 'Resolution', 150)

The LD_PRELOAD fix still applies to R2026b, which ships the same GCC 12 libstdc++.

Figures open off-screen under Hyprland

Figures are XWayland windows (class MATLAB R2026b), and on my two-monitor setup new ones opened left of the screen, at x = -1069. With xwayland:force_zero_scaling, XWayland lays out the outputs in its own order, and here it was the reverse of Hyprland's:

xrandr --listmonitors
#  0: +eDP-1 2880/300x1800/190+0+0  eDP-1
#  1: +DP-5 5120/600x2880/340+2880+0  DP-5
hyprctl monitors -j | jq -c '.[] | {name, x, y}'
# {"name":"eDP-1","x":2560,"y":0}
# {"name":"DP-5","x":0,"y":0}

get(0, 'MonitorPositions') in MATLAB reports the XWayland layout, so the positions it picks, and the ones it remembers, do not match the screens.

A center window rule did not help. Hyprland applied it when the window mapped, then MATLAB moved the window itself. The fix that worked was to re-center the figure from a window.open hook in the Lua config, a moment after MATLAB's own move:

hl.on("window.open", function(win)
    if not (win and win.class and win.class:match("^MATLAB R")) then return end
    local addr = win.address
    hl.timer(function()
        if hl.get_window("address:" .. addr) then
            hl.dispatch(hl.dsp.window.center({ window = "address:" .. addr }))
        end
    end, { timeout = 300, type = "oneshot" })
end)

This only runs when a figure opens. A figure whose Position is set from code afterwards is still placed using the XWayland layout.