Issue Description
This issue is the result of the following glibc bug:
"glibc" is the GNU C Library, which is a core library in Linux distributions. The effects of this bug are more prevalent when a greater number of dynamic libraries are loaded by a particular program. Simulink loads a larger number of dynamic libraries than base MATLAB, which is why this issue is more observable in a MATLAB session where Simulink is loaded compared to when Simulink is not loaded; or when compared to other software.
The glibc bug has been addressed in glibc version 2.35.
Solution
Consider upgrading to a Linux distribution that includes glibc 2.35 and ensure that the glibc.rtld.dynamic_sort=2 tunable is used. This tunable controls the new sorting algorithm that fixes the slowdown. This tunable should be the default setting for most of the Linux distributions that have glibc 2.35 or newer.
To check the glibc version, enter this Linux command:
/lib64/ld-linux-x86-64.so.2 --version
To check the tunables list, enter this Linux command:
/lib64/ld-linux-x86-64.so.2 --list-tunables
- Ubuntu 22.04 LTS and newer
- Fedora 36 and newer
- Arch Linux Release 2022.09.03 and newer
For RHEL/CentOs/AlmaLinux, glibc 2.35 is not available as of the time of this post. The patch was backported to these releases:
- RHEL 8/CentOS 8/AlmaLinux 8: glibc-2.28-221.el8 and newer
- RHEL 9/CentOS 9/AlmaLinux 9: glibc-2.34-28.el9 and newer
Workaround
Unfortunately workarounds are limited. If you are unable to upgrade to a distribution with glibc 2.35 or newer and you are unable to wait for MATLAB to exit on its own, the only workaround currently known is to terminate the MATLAB process with a system command. You can do so with MATLAB code like this:
>>system("kill -9 " + feature('getPID'))
Consider displaying message before doing so, to help distinguish this manual exit from an unexpected crash.