bugGNU Octave - Bugs: bug #35068, segfault when running %!test block...

 
 

bug #35068: segfault when running %!test block with embedded %!function

Submitter:  None
Submitted:  Wed 14 Dec 2011 09:14:04 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Duplicate Assigned to:  None
Originator Name:  Josef Leydold Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.4.3
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 19 Dec 2011 02:24:06 AM UTC, comment #4: 

I have committed a changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/80bda7c4f012) which prevents embedded functions within %!test blocks.  This will stop the segmentation faults and the warning message points directs coders to the syntax which does work (%!function/%!endfunction).  The root cause fix is still to address how subfunctions are handled in Octave.

I am going to close this bug and keep the original report open.

Rik <rik5>
Group administrator
Thu 15 Dec 2011 09:00:20 AM UTC, comment #3: 

Sorry for reporting this known bug but I obviously have missed this entry in the database.

I have found this problem when I wanted to test an oct file where
a function handler is passed to a C routine in a rather complex way. Since octave crashed with a segfault I first assumed that it was my error and spent some time to find the point where my program crashes.

So if there is yet no fix on the development branch may I suggest to report this bug in the Octave manual, e.g. in
Section "F.1 Actual Bugs We Haven't Fixed Yet", and/or even better in Section "B.1 Test Functions".

BTW, there is a typo in the manual in the latter section.
The example

%!function a = fn(b)
%!  a = 2*b;
%!assert (a(2),4);

does not work.

Anyway, thanks a lot for your help.

Josef Leydold <leydold>
Wed 14 Dec 2011 05:11:41 PM UTC, comment #2: 

Actually, there is a workaround.  Use a '%!function' block rather than defining the function within a %!test block.

The following works:


%!function retval = myfunct(x)
%!  retval = exp(-x.*x);
%!endfunction
%!
%!test
%! y = myfunct (10);


Rik <rik5>
Group administrator
Wed 14 Dec 2011 05:05:22 PM UTC, comment #1: 

Alas, this bug has been reported a while back and there is no fix for it yet on the development branch either.  See bug #32843.

Rik <rik5>
Group administrator
Wed 14 Dec 2011 09:14:04 AM UTC, original submission:  

Suppose one has the following test file 'testbug' that just contains the following two lines:


%!test
%!   function retval= myfunct(x) retval = exp(-x.*x); endfunction


and runs this test three times, e.g., by means of the following script 'testbug.m' using 'octave testbug.m'
from the command line:


test testbug verbose
test testbug verbose
test testbug verbose


Then octave crashes with a segfault:


$ octave testbug.m
GNU Octave, version 3.4.3
Copyright (C) 2011 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

Octave was configured for "x86_64-pc-linux-gnu".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.

For information about changes from previous versions, type `news'.

>>>>> /home/leydold/svn/anuran/octave/bug/testbug
  ***** test
   function retval= myfunct(x) retval = exp(-x.*x); endfunction
PASSES 1 out of 1 tests
>>>>> /home/leydold/svn/anuran/octave/bug/testbug
  ***** test
   function retval= myfunct(x) retval = exp(-x.*x); endfunction
PASSES 1 out of 1 tests
>>>>> /home/leydold/svn/anuran/octave/bug/testbug
  ***** test
   function retval= myfunct(x) retval = exp(-x.*x); endfunction
panic: Segmentation fault -- stopping myself...
Segmentation fault


When running octave with valgrind I get the following error report:


==2861== Jump to the invalid address stated on the next line
==2861==    at 0x0: ???
==2861==    by 0x52ED6DC: finish_function(tree_parameter_list*, octave_user_function*, octave_comment_list*) (in /usr/lib64/octave/3.4.3/liboctinterp.so.0.0.0)
==2861==    by 0x52F4CD2: octave_parse() (in /usr/lib64/octave/3.4.3/liboctinterp.so.0.0.0)

[ stuff deleted ]

==2861==  Address 0x0 is not stack'd, malloc'd or (recently) free'd


I guess that octave accidently has freed a function pointer and set it to NULL and then tried to call the function.

I am new to octave so I know too little about the internal structures of octave so I cannot trace down the error.
The call stack before the crash lists functions like 'tree_evaluator::visit_statement' so it happens somewhere in the parse tree of the interpreter.

Josef


Anonymous

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Digest:
   bug dependencies.

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by leydold (Posted a comment)
  • -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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-12-19 rik5 StatusConfirmed Duplicate
        Open/ClosedOpen Closed
    2011-12-14 rik5 StatusNone Confirmed
    2011-12-14 rik5 Summaryoctave segfaults when running test functions segfault when running %!test block with embedded %!function
        Dependencies- Depends on bugs #32843

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code