bugGNU Octave - Bugs: bug #55990, mex() function does not raise...

 
 

bug #55990: mex() function does not raise error when compilation fails

Submitter:  Andrew Janke <apjanke>
Submitted:  Sun 24 Mar 2019 06:59:43 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Matlab Compatibility
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 25 Mar 2019 08:36:02 PM UTC, comment #7: 

I built the latest default and tested it. Looks good to me. Thanks!

Andrew Janke <apjanke>
Mon 25 Mar 2019 08:13:43 PM UTC, comment #6: 

I changed mkoctfile.m to emit an error if there is a problem in compilation and no output was requested here (https://hg.savannah.gnu.org/hgweb/octave/rev/abfae20a2bf7).

I then applied your changes to make mex.m do the same thing.  See https://hg.savannah.gnu.org/hgweb/octave/rev/2b23129f8a96.  I made some other changes along the way such as renaming the output from "retval" to "status" which makes more sense.

Marking as fixed and closing report.

Rik <rik5>
Group administrator
Mon 25 Mar 2019 05:00:44 AM UTC, comment #5: 

I would guess so to. If you do the "easy" thing and write a script with several mkoctfile calls in a row and aren't checking their status, I think you want it to error out if it can't do what you're asking of it.

Andrew Janke <apjanke>
Mon 25 Mar 2019 04:54:00 AM UTC, comment #4: 

That's what I meant.  Matlab user's who have code that they expect to run identically under Octave.

A slightly larger question is whether mkoctfile should also error when using command syntax.  My guess is that it should.

Rik <rik5>
Group administrator
Mon 25 Mar 2019 04:42:43 AM UTC, comment #3: 


> But, I expect Matlab user's will complain that it doesn't throw an error so it should be changed for compatibility.


I think it's more Octave users that would like to re-use code written for Matlab that are affected by this. I'm working with a student who would like to run FieldTrip under Octave.

Andrew Janke <apjanke>
Mon 25 Mar 2019 04:39:32 AM UTC, comment #2: 

Changing Item Group to "Matlab Compatibility".  Octave does issue a warning when compilation fails (you can see it onscreen or check with lastwarn).  You can also check for an error by looking at the return status from mex if you invoke it as a function, rather than using command syntax.

But, I expect Matlab user's will complain that it doesn't throw an error so it should be changed for compatibility.


Rik <rik5>
Group administrator
Sun 24 Mar 2019 07:21:26 PM UTC, comment #1: 

Here's a patch: file #46631

It could go on stable.

It only raises an error when mex's return value is not captured, for back-compatibility with existing usages.

Andrew Janke <apjanke>
Sun 24 Mar 2019 06:59:43 PM UTC, original submission:  

The mex function does not raise an error when compilation fails. This means it's hard for a calling script to detect when mex compilation happens. And for code that's expecting Matlab's mex() behavior of erroring on failure, it can mess up program logic; for example: https://github.com/fieldtrip/fieldtrip/issues/1027.

I think the mex function should error() when compilation does not succeed.

Andrew Janke <apjanke>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #46631:  mex-raise-error-on-failure.patch added by apjanke (2KiB - application/octet-stream)

 

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 apjanke (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-03-25 rik5 StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2019-03-25 rik5 Item GroupIncorrect Result Matlab Compatibility
        StatusNone Confirmed
    2019-03-24 apjanke Attached File- Added mex-raise-error-on-failure.patch, #46631

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code