system() call results in "Signal 126"

4 views (last 30 days)
Martin
Martin on 10 Sep 2015
Answered: Martin on 11 Sep 2015
I'm running Matlab 2015b on Linux (Ubuntu 14.04) and am trying to call an external program using a system call. Even tough I do have the rights to execute the external program, which I verified, a signal 126 "no permission" error occurs. My understanding is, that Matlab should have the same execution rights as my user. Any ideas what could cause the error? I also verified that the file is found.
The Matlab code is available here: https://sites.google.com/site/scarabotix/ocamcalib-toolbox And the line of interest
callBack = system(callString);
is in the file "click_ima_calib.m". Approx line 75.
  2 Comments
Walter Roberson
Walter Roberson on 10 Sep 2015
I suggest you use system('id') to investigate which userid you are running as (just in case), and that you use the Linux ldd inside and outside of MATLAB to (i.e., !ldd ...) to determine whether you have a path problem.
Check in particular whether the binary is suid or guid in case the environment variable changes that MATLAB makes, such as to LD_LIBRARY_PATH, might be affecting whether the binary will execute.
Martin
Martin on 10 Sep 2015
Thank you very much for your advice! I verified that matlab is running with my user id, using system('id'). I also checked, that neither the SUID nor the SGID bit is set and also tested to set them with no effect.
I think the issue might indeed be related to dynamic linking. Calling 'ldd' from outside of Matlab lists around 40 libraries, while 'ldd' from within Matlab lists only about 10 (but no missing libraries are listed). I failed however to obtain the same output, when calling from within Matlab. I tried exporting the paths of missing libraries like this:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu:/usr/lib:/usr/lib64
And checked the result by executing getenv('LD_LIBRARY_PATH') in Matlab. I also experimented with setenv('LD_LIBRARY_PATH', ...) in Matlab without success. Any further ideas?

Sign in to comment.

Accepted Answer

Martin
Martin on 11 Sep 2015
I finally got it. The trick was to completely clear the library path in Matlab:
setenv('LD_LIBRARY_PATH', '');
Honestly, I can only presume why this worked. I realized that Matlab added its own libraries to the path and as a result the executed file linked these, as for example:
libnppc.so.7.0 => /home/martin/Software/Matlab2015b/bin/glnxa64/libnppc.so.7.0 (0x00007f31a243e000)
After clearing 'LD_LIBRARY_PATH', the correct libraries were found. Maybe there was an incompatibility.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!