mxMalloc returns 0xffffffffe03c9460 which I cannot access
Show older comments
Hey there,
I use the NURBs-Toolbox and there are two options, 1 is to use Matlab Files, which is slow but works and the second is use C-Files:
So the Toolbox is about 10 years old, so this could be a problem. If I run the mex-files I get segfaults. So I tried to debug them and the fault is always the same: mxMalloc returns a pointer with 0xffffffff and then something. And then I can't access this array.
double *left = (double*) mxMalloc((p+1)*sizeof(double));
Is the call. The initializing fails, if mxMalloc returns an address at the end of the 48bit area.
I run Ubuntu 10.10 64bit with 64bit Matlab R2010b. Do i compile the files the wrong way or do I have to make some changes because of 64bit pointers?
Thanks
Philipp
Accepted Answer
More Answers (1)
Jan
on 12 Apr 2011
1 vote
Storing the result of an mxMalloc call in an "int" can fail on 64-bit machines: The replied value has 64 bits, the "int" has 32 bits only - usually.
So be sure to use 64 bit variables whenever it is necessary: most of all mwSize, mwIndex, mwSignedIndex are helpful. I've seen an example here, where "ptrdiff_t" helped: Answers: BLAS in mex files
1 Comment
Philipp H
on 12 Apr 2011
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!