Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetCell has problem for Matlab R2012a 32bit, R2012a 64bit, R2013a 64bit in Windows 8 #1

Open
GoogleCodeExporter opened this issue Aug 7, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
0. create a C# project named xxx
1. save a cell v into a mat file using Matlab of above versions
2. mxCellArray v = mxCellArray)mf.GetVariable("v");            
3. v.GetCell(0);
4. run the C# app and when it comes to the end, a window says xxx.exe has 
stopped working. A problem caused the program to stop working correctly. 
Windows will close the program and notify you if a solution is available.

What is the expected output? What do you see instead?
The program should terminate normally.

What version of the product are you using? On what operating system?
As in the title

Please provide any additional information below.

Original issue reported on code.google.com by suhaoch...@gmail.com on 7 Sep 2013 at 10:56

@GoogleCodeExporter
Copy link
Author

I have attached an example test file

Original comment by suhaoch...@gmail.com on 7 Sep 2013 at 11:09

Attachments:

@GoogleCodeExporter
Copy link
Author

If I comment this line in SafeArrayPtr.cs, the bug goes away:

matrix.mxDestroyArray(this.handle);

But I guess it is not so good...

Original comment by suhaoch...@gmail.com on 8 Sep 2013 at 8:42

@GoogleCodeExporter
Copy link
Author

I think I have figured out what happened. The SafeArrayPtr does have some 
problem for recursive data structures such as cell and struct. In 
ReleaseHandle(), mxDestroyArray is called, which is designed by *MATLAB* to 
deallocate memory in a recursive way. In contrary, in this code, mxDestroyArray 
is called at each time an element of the cell array is disposed, including the 
cell array itself. That causes the problem I reported.

Original comment by suhaoch...@gmail.com on 9 Sep 2013 at 7:48

@GoogleCodeExporter
Copy link
Author

I think the only way to resolve the problem is to free the memory manually.

Original comment by suhaoch...@gmail.com on 10 Sep 2013 at 6:06

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant