Matlab 2022a Linux ubuntu18.04安装打开matlab,快速开启simulink后出现 “Assertion `listp != NULL‘ failed! “问题记录

Matlab 2022a Linux "Assertion `listp != NULL' failed! "问题记录

 

尝试Matlab 2021a Linux时,发现某些app必现以下Bug

现象:

app闪退,Matlab闪退,若终端启动,则会提示以下日志

Inconsistency detected by ld.so: ../elf/dl-tls.c: 517: _dl_allocate_tls_init: Assertion `listp != NULL' failed!

解决方法:

搜索日志字符串发现Mathworks Support Team在MATLAB Answers中回答过此bug

Why does MATLAB crash on Linux with "Inconsistency detected by ld.so: ../elf/dl-tls.c: 597: _dl_allocate_tls_init:"​

ww2.mathworks.cn/matlabcentral/answers/1454674-why-does-matlab-crash-on-linux-with-inconsistency-detected-by-ld-so-elf-dl-tls-c-597-_dl_allo

该回答的简单描述为:

这是个在r2021b中已知的外部引起的问题。并提供了三种解决方法

  • Before opening a MATLAB project or running start_simulink, in the Command Window, enter:
    open_system(new_system('abcdef123456')); bdclose('abcdef123456')
  • Upgrade to an operating system version that uses glibc version 2.34 or later.
  • Use https://github.com/mathworks/build-glibc-bz-19329-patch to download patched versions of the glibc libraries, or to build your own versions. Instructions are available in the repository.

这里我使用了第三种方法,现在使用的是glibc 2.31,使用第三种方法打了个patch(如果没有对glibc版本有特定要求,且为了快速解决问题,建议直接升级glibc 2.34,因为第三种方法耗时比较久)。这里打开git,会有mathworks团队对问题更详细的描述,以及为什么给glibc打patch,简短描述为:

此问题最早在2015年12月份被上报,问题是因为glibc中的bug导致,并且在2021年8月份的2.34版本glibc中彻底修复,但此版本glibc目前只默认安装在RHEL 9 beta和Ubuntu 21.10 (Impish Indri),考虑到Ubuntu20.04的生命周期在2030年8月才结束,所以提供了的三种解决方法

而且问题代码也非常简单,就是>=改为>

diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index 073321c..2c9ad2a 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -571,7 +571,7 @@ _dl_allocate_tls_init (void *result)
        }

       total += cnt;
-      if (total >= dtv_slots)
+      if (total > dtv_slots)
        break;

       /* Synchronize with dl_add_to_slotinfo.  */

步骤:

下载代码

    git clone https://github.com/mathworks/build-glibc-bz-19329-patch.git
    cd build-glibc-bz19329-patch

根据自己的系统平台执行对应的Docker指令,以原文为例,使用的为debian:9,那么在终端中执行以下指令(注意有些docker没有加入用户组下,需要添加sudo)

DOCKER_BUILDKIT=1 docker build --build-arg DIST_BASE=debian --build-arg DIST_TAG=9 --output type=local,dest=. .

这里,我的系统为ubuntu 20.04,使用 ubuntu:20.04 ubuntu:focal都可以,那么指令为:

DOCKER_BUILDKIT=1 docker build --build-arg DIST_BASE=ubuntu --build-arg DIST_TAG=focal --output type=local,dest=. .

如果系统为ubuntu 18.04,使用 ubuntu:20.04 ubuntu:bionic都可以,那么指令为:

DOCKER_BUILDKIT=1 docker build --build-arg DIST_BASE=ubuntu --build-arg DIST_TAG=bionic --output type=local,dest=. .

然后慢慢的等待,pull docker image 和编译大概1个多小时,编译出了以下deb

all-packages.tar.gz
glibc-doc_2.31-0ubuntu9.7.ubuntu.focal.custom_all.deb
glibc-source_2.31-0ubuntu9.7.ubuntu.focal.custom_all.deb
libc6_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
libc6-dbg_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
libc6-dev_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
libc6-dev-i386_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
libc6-dev-x32_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
libc6-i386_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
libc6-pic_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
libc6-prof_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
libc6-x32_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
libc-bin_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
libc-dev-bin_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
locales_2.31-0ubuntu9.7.ubuntu.focal.custom_all.deb
locales-all_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
nscd_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb

在安装的时候出了一些小问题,没有安装成功

sudo dpkg -i libc-bin_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb
(Reading database ... 326256 files and directories currently installed.)
Preparing to unpack libc-bin_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb ...
Unpacking libc-bin (2.31-0ubuntu9.7.ubuntu.focal.custom) over (2.31-0ubuntu9.7) ...
dpkg: dependency problems prevent configuration of libc-bin:
 libc-bin depends on libc6 (>> 2.31); however:
  Package libc6:amd64 is not configured yet.
 libc-bin depends on libc6 (<< 2.32); however:
  Package libc6:amd64 is not configured yet.

dpkg: error processing package libc-bin (--install):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 libc-bin

2022.4.28更新

下文标注的斜体原文方法会存在安装后apt-get提示依赖错误的问题。

根据

@一隅天涯

的反馈及其解决方法,使用下面的指令可以解决apt-get依赖问题,同时解决本文要解决的问题,感谢指出!

sudo dpkg -i *.deb

以下原文请勿参考:

经过几次尝试后,安装locals-all*.deb是有效的

sudo dpkg -i locales-all_2.31-0ubuntu9.7.ubuntu.focal.custom_amd64.deb

再次打开Matlab使用对应app,问题解决。

第三种方法有点复杂,所以直接升级glibc版本应该是最快捷的方法。不过由于本身系统环境较多,担心升级glibc版本会出现新问题,还是给现有版本打patch来解决吧。

 

  • 3
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值