mxMalloc returns 0xffffffffe03c9460 which I cannot access

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

 採用された回答

Philipp H
Philipp H 2011 年 4 月 12 日

0 投票

#include "mex.h"
was missing. I feel silly.
Thanks

2 件のコメント

Jan
Jan 2011 年 4 月 12 日
Impressive! The compiler does not show any warnings and is able to compile the file?! Which compiler do you use?
James Tursa
James Tursa 2011 年 4 月 12 日
Likely OP just made function calls w/o any special types used in the code (e.g., mwSize etc.). So the missing prototypes for mxMalloc etc would just generate ("assuming int return" etc) warnings and not errors.

サインインしてコメントする。

その他の回答 (1 件)

Jan
Jan 2011 年 4 月 12 日

1 投票

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 件のコメント

Philipp H
Philipp H 2011 年 4 月 12 日
double *left = (double*) mxMalloc((p+1)*sizeof(double));
This is the Call. Should have posted this earlier. If I initialize the left[0] I get the Segfault.
Thanks.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by