assertion error for persistent memory object
1 回表示 (過去 30 日間)
古いコメントを表示
I have this code in a mex file to interface with a dll.
plhs[0] = mxCreateDoubleMatrix(0, 0, mxREAL);
Status = Reset_Status( In);
mxSetPr(plhs[0], Status);
mxSetM(plhs[0], 10);
mxSetN(plhs[0], 1);
Reset_Status returns a global memory pointer which I want to read out multiple times. On windowsXP 32bit this does not cause problems. On Windows7 32 bit I get an assertion falure;
Assertion failed: Forced Assertion at line 314 of file ".\src\mem\alignment.cpp".
ALIGNMENT ERROR: vector_check: pointer not allocated with vector_*alloc
PID: 2256
NATIVE ALIGNMENT: 8 (0x8)
REQ ALIGNMENT: 16 (0x10)
ALIGNED POINTER: 19BD2168
REQ SIZE: 0 (0)
HEADER ADDRESS: 00000000
HEADER SIZE: 8 (0x8)
HEADER DATA: INACCESSIBLE
How should I resolve this?
0 件のコメント
回答 (1 件)
Kaustubha Govind
2011 年 4 月 14 日
Since all memory held by variables passed in and out of MEX-functions is managed by MATLAB, it is not advisable to use mxSetPr to set (externally owned) data on a variable being returned to MATLAB. There is a danger of that memory being de-allocated by MATLAB.
Instead, I would recommend copying that data from your global buffer into plhs (which must be allocated using a call to mxCreateDoubleMatrix).
As for why this issue is not caught on XP - I wonder if the C runtime libraries are simply more robust on Windows 7?
5 件のコメント
Kaustubha Govind
2011 年 4 月 14 日
+1 for James' comment that the assertion is caused by recent changes to the API - .\src\mem\alignment.cpp does indeed belong inside MATLAB.
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!