Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Mex mxCreateDoubleMatrix() destroys different pointer sporadically
Replies: 1   Last Post: Jan 7, 2013 1:52 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
James Tursa

Posts: 2,094
Registered: 8/5/09
Re: Mex mxCreateDoubleMatrix() destroys different pointer sporadically
Posted: Jan 7, 2013 1:52 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"Max " <maxjaderberg@gmail.com> wrote in message <kcf29j$l93$1@newscl01ah.mathworks.com>...
> I keep running in to segmentation faults when running this Mex file, but it is sporadic and cannot be predicted. The problem comes from the following bit of code:
>
> for (j =0; j<t->neighbors; j++) {
> ...
> ccv_contour_t* cont = t->letters[j]->contour;
> mxArray* S = mxCreateDoubleMatrix(cont->size, 1, mxREAL); //THIS IS THE PROBLEM LINE
> }
>
> Leaving out the mxArray* line, everything works perfectly, however when adding in the line causes the variable cont to sometimes be NULL for some iterations of the loop. I'd say this behaviour happens around 50% of the times I run the exact same code.
>
> It must be something to do with the memory allocated, but I can't figure out what is wrong (and I have spent hours on this now...)


Unable to provide any meaningful comments unless we see your code. The small snippet above is pretty much useless to us.

James Tursa



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.