Matlab crashing in ubuntu when using MATLAB coder
Show older comments
The following error is shown on the terminal:
Inconsistency detected by ld.so: ../elf/dl-tls.c: 517: _dl_allocate_tls_init: Assertion `listp != NULL' failed!
Can someone suggest a fix for this?
Thanks
Siva
8 Comments
Saurabh
on 6 Jul 2022
Hi
It is my understanding that you are witnessing MATLAB crash whenever you are trying to use MATLAB coder. I would request you to provide more system information and MATLAB version. For your convenience, you can try executing "ver -support" command and share the output of the same. Apart from this, you can also refer to the following links which mention similar error as yours –
- https://in.mathworks.com/matlabcentral/answers/1454674-why-does-matlab-crash-on-linux-with-inconsistency-detected-by-ld-so-elf-dl-tls-c-597-_dl_allo
- https://in.mathworks.com/matlabcentral/answers/1567188-simulink-crash-in-ubuntu-20-04?s_tid=srchtitle
Hope it helps!
Raghu Boggavarapu
on 22 Aug 2022
Upgrade to patched version of glibc and try the steps provided in the link above.
xingxingcui
on 9 Mar 2023
Edited: xingxingcui
on 15 Mar 2023
@Raghu Boggavarapu simlar issue:
- host env: ubuntu20.04, matlab R2022b(desktop),opencv4.6(built from source on host),gcc/++ 9.4.0
- docker inner env: ubuntu20.04, matlab R2022b (-browser run),opencv4.6(built from source on docker container),gcc/++ 9.4.0, same as host.
---main reproduce steps----
- I use docker matlab+matlab coder tooolbox to mount bind same folder as host computer.
- docker matlab container install extra opencv c++ library(built from source on docker container).
- use docker matlab coder to generate mex file dependent on opencv c++ library.
- then restart matlab on host ,bug produce above
---------------another mex file issue-------------------------
if i use simple mex file which don't dependent on opencv can both run on host and docker env. however ,once i use matlab coder to generate mex file which dependent opencv can't run on docer env.
Invalid MEX-file
'/home/matlab/matlab_works/buildMapping/codegen_custom_cpp/imread_opencv_mex.mexa64':
libopencv_world.so.406: cannot open shared object file: No such file or
directory
LD_LIBRARY_PATH The path to the opencv installation library has been set correctly and getenv("LD_LIBRARY_PATH") is within the normal setting.
I then used the following system command to check for mex file dependencies:
!ldd -d imread_opencv_mex.mexa64 >./outputDependent.txt
Unfortunately, I didn't find the missing dependencies, the output file is in the attachment I uploaded
NOTE: this imread_opencv_mex.mexa64 file successful produced in docker matlab env,but can't run on it, whereas can run on host matlab env. This is very strange!
Yongjian Feng
on 9 Mar 2023
You are using docker, right? If it can run successfully on the host machine, but not the docker container, maybe it is related to how the docker image is built. Run ldd in both the host and the docker container. Check the version of those libraries your mex depends on. You might need to make sure the same versions of libs are used.
xingxingcui
on 10 Mar 2023
Edited: xingxingcui
on 10 Mar 2023
@Yongjian Feng Hi, thank you for your quickly reply.
Yes, I prefer use docker matlab and want to achieve as consistent as a local Host matlab usage environment as possible.I Checked the version of those libraries my mex depends on.
I use matlab coder toolbox (codegen command line) to generate my mex file successful on docker matlab. This mex file is mouted bind shared on host and docker container.
on docker:
!ldd -d imread_opencv_mex.mexa64 >./outputDependent_docker.txt
on host:
!ldd -d imread_opencv_mex.mexa64 >./outputDependent_host.txt
Then i compare these two file, The problem is that everything looks the same except that the paths to the respective dependent system libraries are different. See attached for comparison results
xingxingcui
on 10 Mar 2023
Edited: xingxingcui
on 10 Mar 2023
@Yongjian Feng I have tried many times to be sure that the docker container has this bug by writing other matlab code(integrate extern opencv c++ code) that depend on opencv c++.
Invalid MEX-file
'/home/matlab/matlab_works/<my_depend_opencv>.mexa64':
libopencv_world.so.406: cannot open shared object file: No such file or directory
Even if I copy the libopencv_world.so.406 file separately and run it in the current directory where the mex file is located, the above error is also reported!
According to the official reference documentation, my problem seem is neither a MEX Version Compatibility issue nor a missing dependency issue, so what is the problem? This is strange.
Reference:
Yongjian Feng
on 10 Mar 2023
Edited: Yongjian Feng
on 10 Mar 2023
The comparison shows more dependencies on the host machine?
One possible way to look for the difference is lddtree. It will give you the hierarchy of ldd. Then you might be able to find out why there are more dependencies on the host machine.
You can also contact Mathworks Techincal Support for this.
Thanks,
Yongjian
xingxingcui
on 21 Mar 2023
Edited: xingxingcui
on 21 Mar 2023
Hi,all:
The problem can finally be solved, thanks to the meticulous and professional investigation by Mathworks Techincal Support, this docker matlab mex opencv error has now been successfully reolved.Not related to matlab coder toolbox.
The problem was that the environment variable LD_LIBRARY_PATH was not effectively recognised by the docker matlab container. The current version of the R2022b container, once built, is not affected by the environment variables set in the container (i.e. neither setting LD_LIBRARY_PAH on the system nor using the setenv function within matlab can actually change its value within the container, even though getenv can ostensibly "show the results in effect").
To properly set environment variables to be passed to matlab, they should be passed directly when matlab is started, e.g. started in the following way.
LD_LIBRARY_PATH="REPLACE/THIS/PATH" matlab
or run matlab container
docker run -d --rm -p <host-port-id>:<contain-port-id> --shm-size=512M -e
LD_LIBRARY_PATH=<my_opencv_lib_dir> <my_image_name>:r2022b -browser
<host-port-id>:Replace with yourself
<container-port-id>:Replace with yourself
<my_opencv_lib_dir> : Replace with your own path
<my_image_name> : Replace with your own name
Answers (1)
xingxingcui
on 28 Mar 2023
Edited: xingxingcui
on 27 Apr 2024
1. Ubuntu 18.04/20.04 has libcanberra-gtk3-module (gtk-3.0+) installed by default, and Matlab needs to call the gtk-2.0+ canberra dynamic link library;
(In fact, there is also a 2.0+ version of the dynamic link library file in the gtk-3.0+ directory, but it seems that Matlab does not support multiple versions of libcanberra-gtk-module.so under the same path)
2. the linux default library is found under the path "/usr/lib/", while the canberra dynamic link library is located under the path "/usr/lib/x86_64-linux-gnu/";
Solution:
1. Install the gtk-2.0+ version of canberra by running the following command in the terminal:
sudo apt-get install libcanberra-gtk-module -y
2. Add a soft connection, run the following command in the terminal (many people are missing this step):
sudo ln -s /usr/lib/x86_64-linux-gnu/gtk-2.0/modules/libcanberra-gtk-module.so /usr/lib/libcanberra-gtk-module.so
-------------------------Off-topic interlude, 2024-------------------------------
I am currently looking for a job in the field of CV algorithm development, based in Shenzhen, Guangdong, China,or a remote support position. I would be very grateful if anyone is willing to offer me a job or make a recommendation. My preliminary resume can be found at: https://cuixing158.github.io/about/ . Thank you!
Email: cuixingxing150@gmail.com
Categories
Find more on Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface) in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!