bugGNU Octave - Bugs: bug #32843, crash when using function defined...

 
 

bug #32843: crash when using function defined in %!test block

Submitted by:  Carlo de Falco <cdf>
Submitted on:  Fri 18 Mar 2011 09:35:08 PM UTC  
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Wont Fix Assigned to:  None
Originator Name:  Open/Closed:  Closed
Release:  dev Operating System:  Mac OS

Add a New Comment (Rich Markup)
   

You are not logged in

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

 

Thu 02 Aug 2012 12:43:06 AM UTC, comment #4: 

Functions in %!test blocks are not allowed.  No segmentation faults will occur because test blocks are scanned for function declarations and any declarations are disallowed.  The solution for %!test blocks which need to have functions is to use the shared function syntax of %!function/%!endfunction.

Rik <rik5>
Project Administrator
Mon 19 Dec 2011 02:26:11 AM UTC, comment #3: 

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.

Rik <rik5>
Project Administrator
Wed 14 Dec 2011 05:13:45 PM UTC, comment #2: 

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

The following works:

%!function p = prova (a)
%!  p = a;
%!endfunction
%!
%!test
%! assert (prova (1), 1);

Rik <rik5>
Project Administrator
Sat 19 Mar 2011 12:38:49 AM UTC, comment #1: 

Confirmed on recent tip (12519:91ccd08fe80c).  There's no reason to even use a for loop, the code always crashes on the 3rd invocation.  Testing was done on a Linux platform indicating it is not just Mac OS which suffers this problem.

For convenience, I've attached the file pippo.m to use when reproducing the problem.

(file #22970)

Rik <rik5>
Project Administrator
Fri 18 Mar 2011 09:35:08 PM UTC, original submission:  

I noticed this bug while testing the patch http://savannah.gnu.org/patch/?7482

I get this consistently reproducible crash with the developers branch on OSX.

Let the file 'pippo.m' contain the following:

%!test
%! function p = prova (a)
%!  p = a;
%! endfunction
%! assert (prova (1), 1);

if I run 'test pippo' once everything works fine, but after repeating the command a few times:

>> for ii=1:10
test pippo
endfor
PASSES 1 out of 1 tests
PASSES 1 out of 1 tests
panic: Bus error -- stopping myself...

c.

Carlo de Falco <cdf>
Project Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #22970:  pippo.m added by rik5 (85B - application/octet-stream)

 

Carbon-Copy List
  • -email is unavailable- added by rik5 (Updated the item)
  • -email is unavailable- added by cdf (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 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-08-02 rik5 StatusConfirmed => Wont Fix
        Open/ClosedOpen => Closed
    2011-12-19 rik5 Summarycrash when repeatedly running a test where a function is defined in the test code => crash when using function defined in %!test block
    2011-12-14 rik5 Dependencies- => bugs #35068 is dependent
    2011-08-11 jwe Dependencies- => bugs #33981 is dependent
    2011-03-19 rik5 Attached File- => Added pippo.m, #22970
        StatusNone => Confirmed

    Back to the top


    Powered by Savane 3.5