cleaning functions in MEX files

3 vues (au cours des 30 derniers jours)
Cédric Devivier
Cédric Devivier le 3 Sep 2011
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 commentaires
Olaf
Olaf le 19 Oct 2011
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 le 20 Oct 2011
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

Connectez-vous pour commenter.

Réponse acceptée

Cédric Devivier
Cédric Devivier le 7 Sep 2012
Modifié(e) : Cédric Devivier le 7 Sep 2012
This problem has been solved in the comments of this file:

Plus de réponses (1)

Jan
Jan le 19 Oct 2011
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 commentaire
Cédric Devivier
Cédric Devivier le 20 Oct 2011
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

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB Compiler dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by