f



matlab crashes (win 7 64 bit) without messages, logs or dumps while using mex-files linked with itpp library and compiled with mingw

Hello,

I know, that this a very special problem and I would like to provide an error log or something like this, but this is the problem.

Following situation:
Matlab 2010a (64bit) on Win 7 64bit Enterprise
Mingw-w64 with basis msys environment
used modified gnumex to create .def and .lib files
mexopt.bat modified to work with mingw

This setup works perfectly. I can write,compile,link and run mex files.
Moreover, I compiled the itpp library with msys/mingw and created static libs as well as shared libs.

Now, the problem:
At the point, when I include an itpp related class of function in the mex file, I can compile and link the mex-file without errors or warnings (except for some ignore statements,'cause of duplicated pathes).

However, when I run the mexfile matlab crashes without messages, logs or dumps. I also used try...catch..., but same behavior.

Well, has anybody an idea how i can debug this? Stepping through the call stack or something like this without logs? Or is there a way to force matlab to go through the steps? 

Any ideas?

Very thanks in advance.

Best regards,
Patrick
0
Patrick
7/20/2010 2:24:04 PM
comp.soft-sys.matlab 211266 articles. 24 followers. lunamoonmoon (257) is leader. Post Follow

2 Replies
1792 Views

Similar Articles

[PageSpeed] 47

"Patrick Grosa" <blubb@nolimitmail.com> wrote in message <i24bi4$q8m$1@fred.mathworks.com>...
> Hello,
> 
> I know, that this a very special problem and I would like to provide an error log or something like this, but this is the problem.
> 
> Following situation:
> Matlab 2010a (64bit) on Win 7 64bit Enterprise
> Mingw-w64 with basis msys environment
> used modified gnumex to create .def and .lib files
> mexopt.bat modified to work with mingw
> 
> This setup works perfectly. I can write,compile,link and run mex files.
> Moreover, I compiled the itpp library with msys/mingw and created static libs as well as shared libs.
> 
> Now, the problem:
> At the point, when I include an itpp related class of function in the mex file, I can compile and link the mex-file without errors or warnings (except for some ignore statements,'cause of duplicated pathes).
> 
> However, when I run the mexfile matlab crashes without messages, logs or dumps. I also used try...catch..., but same behavior.
> 
> Well, has anybody an idea how i can debug this? Stepping through the call stack or something like this without logs? Or is there a way to force matlab to go through the steps? 
> 
> Any ideas?
> 
> Very thanks in advance.
> 
> Best regards,
> Patrick

Debugging MEX-files is difficult, but you can run MATLAB from your debugger, and set your debugger to only step through the code within the MEX-file. There used to be a section in the MATLAB manuals on this, I'm sure it's still there somewhere... :)

The alternative is to write a very simple command-line utility that executes you code. These are usually a lot easier to run in the debugger than the whole of MATLAB.

The thing I would start with: make a very simple MEX-file that links with the library and calls a very simple function in that library. Something you know should never SEGV. If this MEX-file doesn't work, you have a linking problem. If the library is linked dynamically, is it available on the PATH within MATLAB? Try the dependency walker to check you MEX-file for linked libraries and such: http://www.dependencywalker.com/

Good luck!
Cris.
0
7/20/2010 2:54:04 PM
Hello Chris,

Thank you for the advise. I realized that mex files are a very tricky thing.

I used eclipse and the gnu-debugger to attach to matlab and set a breakpoint at the very first beginning of this short main function:

#include <iostream>
#include <string>
#include <itpp/itmex.h>
//#include "mex.h"
using namespace std;

void mexFunction(int n_output, mxArray *output[], int n_input, const mxArray *input[])
{
itpp::vec b;//=itpp::linspace(10,10,20);
int a=10;
a=a+2;// Check the number of inputs and output arguments
if(n_output!=0) mexErrMsgTxt("Wrong number of output variables!");
if(n_input!=0) mexErrMsgTxt("Wrong number of input variables!");
mexErrMsgTxt("Super3");
return;
}

But the program never comes to this point, matlab crashes before. Well if i comment out the line "itpp::vec b;" everything works fine.

I also assumed a dependency problem and used the dependency walker at first called by double-click and then navigating to the file and afterwards, called from within matlab by a system('....') call in order to see the same pathes as matlab. And everything seems fine...

But one thing that I'm thinking about is the dependency of the itpp library on the blas, lapack and fftw3 library. I compiled them on my own and linked them to the itpp library. However, I didn't used the libs shipped with matlab. 

Does you or anybody else if these links are automatically loaded by matlab by default? Maybe, this could produce the crash?

Thanks a lot again,
discussing the possibilities help a lot to find a solution

best regards,
Patrick


"Cris Luengo" <cris.luengo@google.for.my.name.to.contact.me> wrote in message <i24dac$n79$1@fred.mathworks.com>...
> "Patrick Grosa" <blubb@nolimitmail.com> wrote in message <i24bi4$q8m$1@fred.mathworks.com>...
> > Hello,
> > 
> > I know, that this a very special problem and I would like to provide an error log or something like this, but this is the problem.
> > 
> > Following situation:
> > Matlab 2010a (64bit) on Win 7 64bit Enterprise
> > Mingw-w64 with basis msys environment
> > used modified gnumex to create .def and .lib files
> > mexopt.bat modified to work with mingw
> > 
> > This setup works perfectly. I can write,compile,link and run mex files.
> > Moreover, I compiled the itpp library with msys/mingw and created static libs as well as shared libs.
> > 
> > Now, the problem:
> > At the point, when I include an itpp related class of function in the mex file, I can compile and link the mex-file without errors or warnings (except for some ignore statements,'cause of duplicated pathes).
> > 
> > However, when I run the mexfile matlab crashes without messages, logs or dumps. I also used try...catch..., but same behavior.
> > 
> > Well, has anybody an idea how i can debug this? Stepping through the call stack or something like this without logs? Or is there a way to force matlab to go through the steps? 
> > 
> > Any ideas?
> > 
> > Very thanks in advance.
> > 
> > Best regards,
> > Patrick
> 
> Debugging MEX-files is difficult, but you can run MATLAB from your debugger, and set your debugger to only step through the code within the MEX-file. There used to be a section in the MATLAB manuals on this, I'm sure it's still there somewhere... :)
> 
> The alternative is to write a very simple command-line utility that executes you code. These are usually a lot easier to run in the debugger than the whole of MATLAB.
> 
> The thing I would start with: make a very simple MEX-file that links with the library and calls a very simple function in that library. Something you know should never SEGV. If this MEX-file doesn't work, you have a linking problem. If the library is linked dynamically, is it available on the PATH within MATLAB? Try the dependency walker to check you MEX-file for linked libraries and such: http://www.dependencywalker.com/
> 
> Good luck!
> Cris.
0
blubb (1)
7/20/2010 5:20:22 PM
Reply: