cleaning functions in MEX files

2 次查看(过去 30 天)
Dear all,
I have some issues with MATLAB cleaning functions in MEX files. In the link below is a zip file containing the c++ code, some data to test it and a m file to build it and run it.
I was able to compile it under linux before but from a system upgrade it won't anymore. I narrowed the problem down to the cleaning part when returning to windows but my knowledge in c++ stops here. I didn't wrote the code myself (I adapted it for matlab and the large arrays dim).
Thank you for your help,
Cédric
  2 个评论
Olaf
Olaf 2011-10-19
Hi Cédric,
Have you solved the problem already? If not, can you provide an example you would call mf2 from the Matlab prompt? What exactly did you mean by the "cleaning part"?
Olaf
Cédric Devivier
Cédric Devivier 2011-10-20
Hi Olaf,
I have not solved this issue yet.
If you download and unzip the mf2.zip file, open the compile.m file in the mf2 folder newly created.
You will see issues if not after the first run, run again 'cutsideg = mf2(sourcesinkg,remaing);' a couple of times.
"The cleaning part" means when the mex file is exiting and returning to MATLAB. I used valgrind and gdb and it didn't find any errors, but when I run the same mexa64 compiled file, it crashes.
Thanks for your help,
Cédric

请先登录,再进行评论。

采纳的回答

Cédric Devivier
Cédric Devivier 2012-9-7
编辑:Cédric Devivier 2012-9-7
This problem has been solved in the comments of this file:

更多回答(1 个)

Jan
Jan 2011-10-19
This will fail if the input is a DOUBLE array:
float *sourcesinkVal;
sourcesinkVal = (float *) mxGetPr(prhs[0]);
Better use:
float *sourcesinkVal;
if (!mxIsSingle(prhs[0])) {
mexErrMsgTxt("1st input must be a SINGLE.");
}
sourcesinkVal = (float *) mxGetData(prhs[0]);
It is not clear where the function crashs. Please post more details.
  1 个评论
Cédric Devivier
Cédric Devivier 2011-10-20
Hi Jan,
Thanks for your remark, I added the same for the second input.
As I said to Olaf, MATLAB crashes when I run it. And from the crash dump, the begining looks like:
Abnormal termination:
Abort signal
In my understanding, this routine does not clean properly the variables it created. Also sometimes, I have an error like that:
"glibc detected *** corrupted double-linked list"
Thanks for your help,
Cédric

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB Compiler 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by