The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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,326
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 " <> wrote in message <kcf29j$l93$>...
> 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]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.