bugGNU Octave - Bugs: bug #60209, octave crashes when some .oct...

 
 

bug #60209: octave crashes when some .oct files are updated

Submitter:  None
Submitted:  Wed 10 Mar 2021 05:39:29 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  3 - Low Item Group:  Segfault, Bus Error, etc.
Status:  Confirmed Assigned to:  None
Originator Name:  David Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * 6.2.0
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 10 Mar 2021 11:22:23 PM UTC, comment #2: 

Uploading the C++ file I used for testing (crashtest.cpp).  The example in comment #0 had "#include <armadillo>" which was not required to see this bug.

(file #51043)

Rik <rik5>
Group administrator
Wed 10 Mar 2021 11:14:29 PM UTC, comment #1: 

Confirmed.  Behavior is also present on the development branch.

I would say that this is a corner case and there is an easy workaround.  Clear the reference to the function in the Octave interpreter before overwriting the file on disk.

If, for example, you are in a code/compile/debug loop for a .oct file then the only addition to this is


clear -f NAME_OF_FUNCTION


after you are done debugging and ready to change the code, compile, and overwrite the existing .oct file.

Because there is a simple way to avoid this I'm lowering the priority, but it would still be nice to figure out why this isn't working.

Rik <rik5>
Group administrator
Wed 10 Mar 2021 05:39:29 PM UTC, original submission:  

A .oct file derived from the crashtest.cpp source code below causes octave to crash when it is run, updated (ie, the file is modified), and run again with this error on my Ubuntu 20.04 system with octave 6.2.0 built and installed from source:

fatal: caught signal Segmentation fault -- stopping myself...
Segmentation fault (core dumped)

Contents of crashtest.cpp which was copied from the example here:
https://octave.org/doc/v6.1.0/Getting-Started-with-Oct_002dFiles.html
with the addition of one line which includes <armadillo>

#include <octave/oct.h>
#include <armadillo>
using namespace std;
DEFUN_DLD (crashtest, args, nargout,
           "Hello World Help String")
{
  octave_stdout << "First version of Hello World has "
                << args.length () << " input arguments and "
                << nargout << " output arguments.\n";
  octave_value_list retval (nargout);
  for (int i = 0; i < nargout; i++)
    retval(i) = octave_value (Matrix ());

  return retval;
}


The way I reliably reproduce this problem is to:
1) compile like this:
mkoctfile -o crashtesttmp crashtest.cpp
cp crashtesttmp.oct crashtest.oct
2) start octave and call crashtest()
3) from another shell, recopy crashtest.oct:
cp crashtesttmp.oct crashtest.oct
4) from the shell running the octave session, call crashtest() again.

For me, this causes octave to reliably crash. Recompiling without going through the crashtesttmp.oct intermediate file doesn't crash but instead outputs a message like this:
warning: library /tmp/crashtest.oct not reloaded due to existing references

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #51043:  crashtest.cpp added by rik5 (429B - text/x-c++src)

 

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 None (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-03-10 rik5 Attached File- Added crashtest.cpp, #51043
    2021-03-10 rik5 Priority5 - Normal 3 - Low
        StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code