bugGNU Octave - Bugs: bug #48949, mexCallMATLABWithTrap not...


bug #48949: mexCallMATLABWithTrap not implemented

Submitted by:  Guillaume <gyom>
Submitted on:  Tue 30 Aug 2016 10:42:32 AM UTC  
Category:  Libraries Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Feature Request
Status:  Fixed Assigned to:  None
Originator Name:  Guillaume Open/Closed:  Closed
Release:  dev Operating System:  Any

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


( Jump to the original submission)

Thu 08 Sep 2016 11:14:33 PM UTC, comment #6:

I also made the default value of the TrapFlag to be 0 to match Matlab (http://hg.savannah.gnu.org/hgweb/octave/rev/3a8af9d517de). Previously Octave was behaving as if TrapFlag was set.

Rik <rik5>
Project Administrator
Thu 08 Sep 2016 11:03:29 PM UTC, comment #5:

I added mexCallMATLABWithTrap to the MEX API in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/ad5439817753). I mostly followed your suggestion, but the new code saves and restores the TrapFlag in case it is not 1 when entering the function. I also used Octave coding conventions for the alignment of the code and for the error id and message.

Rik <rik5>
Project Administrator
Thu 08 Sep 2016 10:04:58 PM UTC, comment #4:

Re-titling bug report for remaining issue.

Rik <rik5>
Project Administrator
Thu 08 Sep 2016 10:04:34 PM UTC, comment #3:

I made the change you suggested to get the correct status from mexCallMATLAB in this cset (http://hg.savannah.gnu.org/hgweb/octave/rev/2fb86778f78d).

Rik <rik5>
Project Administrator
Mon 05 Sep 2016 04:32:21 PM UTC, comment #2:

I actually conflated two issues in this bug report: one bug with mexCallMATLAB and a feature request with mexCallMATLABWithTrap.

  • bug report concerning mexCallMATLAB:

The integer value returned by mexCallMATLAB is always 1 even if an error has been caught. This can be fixed with the following (this is what mexEvalString does):

  • feature request for mexCallMATLABWithTrap:

Given that the try/catch ME currently returns a structure, the following could be used until a complete MException can be returned:

Guillaume <gyom>
Tue 30 Aug 2016 01:37:27 PM UTC, comment #1:

I've just made the following tiny change:

and it now returns a non zero value when an error is caught. The error message is still being displayed though:

Maybe the same approach than the one used by @oheim in patch #8033 can be used here.

Guillaume <gyom>
Tue 30 Aug 2016 10:42:32 AM UTC, original submission:

It seems that mexCallMATLABWithTrap is not available from the Octave API:

I tried instead to use mexCallMATLAB with mexSetTrapFlag, even if its use is deprecated in MATLAB, as it seems to be implemented in Octave:

There seems to be an issue with the integer value returned by mexCallMATLAB though:

With mexSetTrapFlag(0), Octave gives:

With mexSetTrapFlag(0), MATLAB gives:

With mexSetTrapFlag(1), Octave gives:

With mexSetTrapFlag(1), MATLAB gives:

So it seems that when the Trap Flag is set to true, mexCallMATLAB is not set to a non-zero value when an error is caught.

From what I see, it seems that having an implementation of mexCallMATLABWithTrap might not be too difficult - the main issue being that MException is not implemented: what are the plans regarding this and should it be implemented in M-code or C++?

Guillaume <gyom>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by gyom (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2016-09-08 rik5 StatusNone => Fixed
        Open/ClosedOpen => Closed
    2016-09-08 rik5 SummarymexCallMATLABWithTrap not implemented and problem with mexCallMATLAB/mexSetTrapFlag => mexCallMATLABWithTrap not implemented

    Back to the top

    Powered by Savane 3.4