Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.



Re: Mex mxCreateDoubleMatrix() destroys different pointer sporadically
Posted:
Jan 7, 2013 1:52 PM


"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



