bugGNU Octave - Bugs: bug #55787, Old .mex file (e.g. ver4.4)...


bug #55787: Old .mex file (e.g. ver4.4) crashes new Octave

Submitted by:  Eddy <count>
Submitted on:  Tue 26 Feb 2019 11:13:44 PM UTC  
Category:  Interpreter Severity:  2 - Minor
Priority:  3 - Low Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

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


Wed 27 Feb 2019 12:23:00 AM UTC, comment #3: 

Thanks for the quick verification.

You could try a utility like 'patchelf' to remove the DT_NEEDED entries from the ELF header in your existing mex files.

Mike Miller <mtmiller>
Project Administrator
Wed 27 Feb 2019 12:00:20 AM UTC, comment #2: 

Tested your suggestion (strip -loctinterp -loctave). Now no crash. Thanks!

Just one final question, is it possible to NOT rebuild every .mex files, while get them work? Such as LD_PRELOAD something? If no easy way, I'm fine with the rebuild.

Eddy <count>
Tue 26 Feb 2019 11:45:26 PM UTC, comment #1: 

Thanks for your bug report. I can sort of reproduce this, Octave does not crash for me, but it does SIGABRT when exiting due to an invalid pointer.

I think the main problem here is that the .mex file from Octave 4.4 is linked against liboctave and liboctinterp from Octave 4.4. This was due to the build instructions that were hard coded into the mkoctfile program that always built with "-loctinterp -loctave". This forces Octave 5 to load the Octave 4.4 libraries when the mex file is loaded, causing conflicts.

This is fixed in Octave 5 to not link against those libraries now, since they are not normally needed when building an extension or plugin type shared object that will be dlopen'd by Octave.

There is no way to override these options in Octave 4.4, so the only way you can test that this fixes it for you is to do something like this

$ cmds=$(mkoctfile-4.4.1 --mex --verbose hello.c)
$ eval "$(echo "$cmds" | sed 's/ -loctinterp -loctave//')"

That will build a mex file with Octave 4.4, but without the hard links to its libraries. Can you test that and see whether you can run the resulting mex file in Octave 5 or 6 without the same crash or error? Thanks.

If that works for you, then we can call this fixed in Octave 5 already.

Mike Miller <mtmiller>
Project Administrator
Tue 26 Feb 2019 11:13:44 PM UTC, original submission:  

Although I don't expect Octave to be backward compatible in binary level. It should probably not to crash at least, IMHO.

I hit this problem unexpectedly by

$ ./octave-cli -q
octave-cli:1> lookfor 'some words'
Segmentation fault

Only after printing the backtrace, I finally realize that my default '.octaverc' includes some path of old .mex files, then lookfor eventually calls dlopen() and fail.

On Windows 10 x64, Octave 5.1 works find in this case (not extensively tested), with .mex compiled by Octave 4.4.1.
I didn't try Octave 5.1 on Linux.

Matlab seems can read both .mex generated by Octave 4.4 or current development version.

For your convenient, a hello world mex file is attached.

Maybe related bug: #36067.

Eddy <count>


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

Attach Files:

Attached Files
file #46360:  ohello.cpp added by count (352B - text/x-c++src - hello world mex file)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by count (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-02-27 mtmiller StatusNeed Info => Fixed
        Open/ClosedOpen => Closed
    2019-02-26 mtmiller Severity3 - Normal => 2 - Minor
        Priority5 - Normal => 3 - Low
        StatusNone => Need Info
    2019-02-26 count Attached File- => Added ohello.cpp, #46360

    Back to the top

    Powered by Savane 3.5