Discussion:
mex file return value corruption?
(too old to reply)
Ross Anderson
2009-12-22 02:14:04 UTC
Permalink
Hi all,
I've come across this several times, and I was wondering if anyone has a solution figured out.
When I call my mex function
myfunction(1,1,3)
with no return value, everything works fine, with or without a semicolon.
I can then save value=ans; and have access to the output.
If I call
value=myfunction(1,1,3)
I get a segmentation fault (red lettering, but no crash).

Without posting code, does this ring a bell as to what is wrong? Or maybe at least why it happens this way?
Jan Simon
2009-12-22 07:28:05 UTC
Permalink
Dear Ross!
Post by Ross Anderson
When I call my mex function
myfunction(1,1,3)
with no return value, everything works fine, with or without a semicolon.
I can then save value=ans; and have access to the output.
If I call
value=myfunction(1,1,3)
I get a segmentation fault (red lettering, but no crash).
The only difference inside the MEX is the value of [nlhs]. So perhaps you find the bug by searching commands, which depend on this variable.

Kind regards, Jan

Loading...