Matlab from command line (-nodisplay -nojvm) segmentation violation on exit, on Mac OS
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Certain programs crash when I try to exit them from the command line (or call them within Python). (The weird thing is I have not been able to determine what causes some programs to crash and some not to.) So e.g. here is a very simple Matlab program (bugtest.m) which does crash:
function bugtest(ifile, ofile)
data = csvread(ifile, 1, 0); % skip the first line
csvwrite(ofile, data);
end
Now, when I call it from the command line, and exit separately, it works fine:
bash> /Applications/MATLAB_R2018b.app/bin/matlab -nodisplay -nojvm -r "bugtest('z2.csv','z3.csv')"
< M A T L A B (R) >
Copyright 1984-2018 The MathWorks, Inc.
R2018b (9.5.0.944444) 64-bit (maci64)
August 28, 2018
For online documentation, see https://www.mathworks.com/support
For product information, visit www.mathworks.com.
>> exit
exit
But what I actually want it to do is to exit as well, i.e. include the exit on the command line, and it crashes (depending on the program, but the program bugtest.m always crashes):
bash> /Applications/MATLAB_R2018b.app/bin/matlab -nodisplay -nojvm -r "bugtest('z2.csv','z3.csv');exit"
< M A T L A B (R) >
Copyright 1984-2018 The MathWorks, Inc.
R2018b (9.5.0.944444) 64-bit (maci64)
August 28, 2018
For online documentation, see https://www.mathworks.com/support
For product information, visit www.mathworks.com.
--------------------------------------------------------------------------------
Segmentation violation detected at Thu Aug 22 15:55:40 2019 +0930
--------------------------------------------------------------------------------
How do I fix this?
3 comentarios
Aakriti Suman
el 26 de Mzo. de 2020
Hi Peter,
Could you please send us the csv files that you are using in your MATLAB code? It will help us in investigating your query better.
Respuestas (1)
Aakriti Suman
el 27 de Mzo. de 2020
Editada: Aakriti Suman
el 27 de Mzo. de 2020
I understand that you are not able to execute a user defined function and the 'exit' command one after the other at once through the command line.
I tried to execute a simple script as below.
function bugtest(a)
sum = a+2;
disp(sum)
end
Through the command line, I called the above function in two ways:
- >>bugtest(2)
>>exit
- >>bugtest(2);exit
In both the above ways, my MATLAB did not crash and the MATLAB window exited normally.
Since you are using python as a third party tool, there is a slight possibility that the usage of both the tools simulataneously is not being used correctly.
I also see that you are using R2019 version of MATLAB. 'csvread' function has compatibility issues with MATLAB R2019a and later versions.
You can use 'readmatrix' instead of 'csvread' function. I am attaching its documentation link for your reference.
0 comentarios
Ver también
Categorías
Más información sobre Call Python from MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!