bugGNU Octave - Bugs: bug #33981, function in %!demo block leads to...

 
 

bug #33981: function in %!demo block leads to crash

Submitter:  John W. Eaton <jwe>
Submitted:  Wed 10 Aug 2011 03:52:39 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  jwe 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

Thu 02 Aug 2012 12:40:25 AM UTC, comment #6: 

Functions in demo blocks are allowed now that support for nested functions has been added to Octave.  The code which tested and prevented declaring functions in demo blocks has been removed in this changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/dda73cb60ac5).

Rik <rik5>
Group administrator
Wed 01 Aug 2012 04:48:51 PM UTC, comment #5: 

That change seems OK to me.

Thanks.

John W. Eaton <jwe>
Group administrator
Wed 01 Aug 2012 04:45:31 PM UTC, comment #4: 

John, the issue in this bug report has gone away thanks to support for nested functions.  I am thinking of removing the code which tests for the presence of a function within a demo block and reports an error if a function is found.  Is there any objection?

I think I will leave the code which checks for functions in %!test blocks so that there is still a preference to use the %!function/%!endfunction syntax.  I think forcing the programmer to be explicit about creating a shared test function is not a bad idea.

Rik <rik5>
Group administrator
Mon 19 Dec 2011 02:25:07 AM UTC, comment #3: 

I have committed a changeset (http://hg.savannah.gnu.org/hgweb/octave/rev/80bda7c4f012) which prevents embedded functions within %!test and %!demo 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>
Group administrator
Thu 11 Aug 2011 12:40:11 PM UTC, comment #2: 

Thanks.  I thought I had seen something like this report earlier, but I didn't search for it.  I've linked these two bug reports.

John W. Eaton <jwe>
Group administrator
Thu 11 Aug 2011 05:21:14 AM UTC, comment #1: 

The same happens id 'test' is used instead of 'demo':


%!test
%! function f ()
%! endfunction
%! f ()


I think this bug is related to the one reported in

http://savannah.gnu.org/bugs/?32843

here is the backtrace of the crash in this case:


#0  0x00000000 in ?? ()
#1  0x00067705 in symbol_table::unmark_forced_variables () at /Users/carlo/Desktop/OF/octave/octave/src/symtab.h:2971
#2  0x00067705 in finish_function (ret_list=0x3a7fbd4, fcn=0x306733c, lc=0x0) at oct-parse.yy:2971
#3  0x0006e5fb in octave_parse () at oct-parse.yy:1357
#4  0x0033595f in eval_string (s=@0xbfffb258, silent=false, parse_status=@0xbfffb318, nargout=0) at oct-parse.yy:4332
#5  0x00336914 in eval_string (arg=<value temporarily unavailable, due to optimizations>, silent=false, parse_status=@0xbfffb318, nargout=0) at oct-parse.yy:4424
#6  0x003378af in Feval (args=@0x3ac3d08, nargout=0) at oct-parse.yy:4472
#7  0x004b1fe4 in octave_builtin::do_multi_index_op (this=0x30c8ea0, nargout=0, args=@0x3ac3d08, lvalue_list=0x0) at ov-builtin.cc:131
#8  0x004b0c36 in octave_builtin::subsref (this=0x30c8ea0, type=@0xbfffb7f4, idx=@0xbfffb7ac, nargout=0, lvalue_list=0x0) at ov-builtin.cc:64
#9  0x004b160a in octave_builtin::subsref (this=0x30c8ea0, type=@0xbfffb7f4, idx=@0xbfffb7ac, nargout=0) at ov-builtin.cc:47
#10 0x005dd21d in octave_value::subsref (this=0xbfffb7cc, type=@0xbfffb7f4, idx=@0xbfffb7ac, nargout=0) at ov.cc:1201
#11 0x005ddae5 in octave_value::subsref (this=0xbfffb7cc, type=@0xbfffb7f4, idx=@0xbfffb7ac, nargout=0, lvalue_list=0x0) at ov.cc:1212
#12 0x006b5028 in tree_index_expression::rvalue (this=0x3ae3cd0, nargout=0, lvalue_list=0x0) at pt-idx.cc:407
#13 0x006b52ea in tree_index_expression::rvalue (this=0x3ae3cd0, nargout=0) at pt-idx.cc:277
#14 0x006b40b2 in tree_index_expression::rvalue1 (this=0x3ae3cd0, nargout=0) at pt-idx.cc:418
#15 0x006a7213 in tree_evaluator::visit_statement (this=0xf72d40, stmt=@0x3ae3db0) at pt-eval.cc:737
#16 0x006d7eb1 in tree_statement::accept (this=0x3ae3db0, tw=@0xf72d40) at pt-stmt.cc:151
#17 0x006a5c95 in tree_evaluator::visit_statement_list (this=0xf72d40, lst=@0x3ae3e20) at pt-eval.cc:773
#18 0x0008822b in tree_statement_list::accept (this=0x3ae3e20, tw=@0xf72d40) at pt-stmt.cc:215
#19 0x006a5dd1 in tree_evaluator::visit_try_catch_command (this=0xf72d40, cmd=@0x3ae5780) at pt-eval.cc:889
#20 0x006a9927 in tree_try_catch_command::accept (this=0x3ae5780, tw=@0xf72d40) at pt-except.cc:69
#21 0x006a7163 in tree_evaluator::visit_statement (this=0xf72d40, stmt=@0x3ae5410) at pt-eval.cc:707
#22 0x006d7eb1 in tree_statement::accept (this=0x3ae5410, tw=@0xf72d40) at pt-stmt.cc:151
#23 0x006a5c95 in tree_evaluator::visit_statement_list (this=0xf72d40, lst=@0x3ae57b0) at pt-eval.cc:773
#24 0x0008822b in tree_statement_list::accept (this=0x3ae57b0, tw=@0xf72d40) at pt-stmt.cc:215
#25 0x006a7463 in tree_evaluator::visit_if_command_list (this=0xf72d40, lst=@0x3ae57d0) at pt-eval.cc:574
#26 0x006d6ba8 in tree_if_command_list::accept (this=0x3ae57d0, tw=@0xf72d40) at pt-select.cc:83
#27 0x006a74c7 in tree_evaluator::visit_if_command (this=0xf72d40, cmd=@0x3ae5a10) at pt-eval.cc:552
#28 0x006d6bc2 in tree_if_command::accept (this=0x3ae5a10, tw=@0xf72d40) at pt-select.cc:108
#29 0x006a7163 in tree_evaluator::visit_statement (this=0xf72d40, stmt=@0x3ae57f0) at pt-eval.cc:707
#30 0x006d7eb1 in tree_statement::accept (this=0x3ae57f0, tw=@0xf72d40) at pt-stmt.cc:151
#31 0x006a5c95 in tree_evaluator::visit_statement_list (this=0xf72d40, lst=@0x3acc0b0) at pt-eval.cc:773
#32 0x0008822b in tree_statement_list::accept (this=0x3acc0b0, tw=@0xf72d40) at pt-stmt.cc:215
#33 0x006a8463 in octave_quit [inlined] () at /Users/carlo/Desktop/OF/octave/octave/libcruft/misc/quit.h:360
#34 0x006a8463 in quit_loop_now [inlined] () at /Users/carlo/Desktop/OF/octave/octave/src/pt-eval.cc:266
#35 0x006a8463 in tree_evaluator::visit_simple_for_command (this=0xf72d40, cmd=@0x3ae8b60) at pt-eval.cc:360
#36 0x006b739e in tree_simple_for_command::accept (this=0x3ae8b60, tw=@0xf72d40) at pt-loop.cc:115
#37 0x006a7163 in tree_evaluator::visit_statement (this=0xf72d40, stmt=@0x3acb510) at pt-eval.cc:707
#38 0x006d7eb1 in tree_statement::accept (this=0x3acb510, tw=@0xf72d40) at pt-stmt.cc:151
#39 0x006a5c95 in tree_evaluator::visit_statement_list (this=0xf72d40, lst=@0x2e6dcd0) at pt-eval.cc:773
#40 0x0008822b in tree_statement_list::accept (this=0x2e6dcd0, tw=@0xf72d40) at pt-stmt.cc:215
#41 0x005c4e74 in octave_user_function::do_multi_index_op (this=0x3066f70, nargout=0, args=@0x3a7bd38, lvalue_list=0x0) at ov-usr-fcn.cc:476
#42 0x005c5cfc in octave_user_function::subsref (this=0x3066f70, type=@0xbfffc394, idx=@0xbfffc34c, nargout=0, lvalue_list=0x0) at ov-usr-fcn.cc:326
#43 0x005c6bb6 in octave_user_function::subsref (this=0x3066f70, type=@0xbfffc394, idx=@0xbfffc34c, nargout=0) at ov-usr-fcn.cc:309
#44 0x005dd21d in octave_value::subsref (this=0xbfffc36c, type=@0xbfffc394, idx=@0xbfffc34c, nargout=0) at ov.cc:1201
#45 0x005ddae5 in octave_value::subsref (this=0xbfffc36c, type=@0xbfffc394, idx=@0xbfffc34c, nargout=0, lvalue_list=0x0) at ov.cc:1212
#46 0x006b5028 in tree_index_expression::rvalue (this=0x3ac71a0, nargout=0, lvalue_list=0x0) at pt-idx.cc:407
#47 0x006b52ea in tree_index_expression::rvalue (this=0x3ac71a0, nargout=0) at pt-idx.cc:277
#48 0x006b40b2 in tree_index_expression::rvalue1 (this=0x3ac71a0, nargout=0) at pt-idx.cc:418
#49 0x006a7213 in tree_evaluator::visit_statement (this=0xf72d40, stmt=@0x39e9b50) at pt-eval.cc:737
#50 0x006d7eb1 in tree_statement::accept (this=0x39e9b50, tw=@0xf72d40) at pt-stmt.cc:151
#51 0x006a5c95 in tree_evaluator::visit_statement_list (this=0xf72d40, lst=@0x39de9e0) at pt-eval.cc:773
#52 0x0008822b in tree_statement_list::accept (this=0x39de9e0, tw=@0xf72d40) at pt-stmt.cc:215
#53 0x0042c5c5 in main_loop () at toplev.cc:573
#54 0x003c1295 in octave_main (argc=6, argv=0xbfffc724, embedded=0) at octave.cc:935
#55 0x00001f80 in main (argc=6, argv=0xbfffc724) at main.c:35


Carlo de Falco <cdf>
Group Member
Wed 10 Aug 2011 03:52:39 PM UTC, original submission:  

Given a demo block in a .m file that contains a function definition, executing demo for that .m file three times will crash Octave.  The demo block can be as simple as


%!demo
%! function f ()
%! endfunction
%! f ()


Here is a stack trace of the crash:


Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) where
#0  0x0000000000000000 in ?? ()
#1  0x00007ffff73465b4 in finish_function (ret_list=0x0, fcn=0x6b4760, lc=0x0)
    at oct-parse.yy:2971
#2  0x00007ffff7341b12 in octave_parse () at oct-parse.yy:1357
#3  0x00007ffff734ae70 in eval_string (s=..., silent=false,
    parse_status=@0x7fffffffc14c, nargout=0) at oct-parse.yy:4332
#4  0x00007ffff734b357 in eval_string (arg=..., silent=false,
    parse_status=@0x7fffffffc14c, nargout=0) at oct-parse.yy:4424
#5  0x00007ffff734b46d in Feval (args=..., nargout=0) at oct-parse.yy:4472
#6  0x00007ffff745435c in octave_builtin::do_multi_index_op (this=0x76f878,
    nargout=0, args=..., lvalue_list=0x0)
    at /home/jwe/src/octave/src/ov-builtin.cc:131
#7  0x00007ffff7454000 in octave_builtin::subsref (this=0x76f878, type=...,
    idx=..., nargout=0, lvalue_list=0x0)
    at /home/jwe/src/octave/src/ov-builtin.cc:64
#8  0x00007ffff7453eee in octave_builtin::subsref (this=0x76f878, type=...,
    idx=..., nargout=0) at /home/jwe/src/octave/src/ov-builtin.cc:47
#9  0x00007ffff74e4530 in octave_value::subsref (this=0x7fffffffc560,
    type=..., idx=..., nargout=0) at /home/jwe/src/octave/src/ov.cc:1201
#10 0x00007ffff74e45d8 in octave_value::subsref (this=0x7fffffffc560,
    type=..., idx=..., nargout=0, lvalue_list=0x0)
    at /home/jwe/src/octave/src/ov.cc:1212
#11 0x00007ffff7566d08 in tree_index_expression::rvalue (this=0x7dc7e0,
---Type <return> to continue, or q <return> to quit---
    nargout=0, lvalue_list=0x0) at /home/jwe/src/octave/src/pt-idx.cc:407
#12 0x00007ffff7566457 in tree_index_expression::rvalue (this=0x7dc7e0,
    nargout=0) at /home/jwe/src/octave/src/pt-idx.cc:277
#13 0x00007ffff7566f62 in tree_index_expression::rvalue1 (this=0x7dc7e0,
    nargout=0) at /home/jwe/src/octave/src/pt-idx.cc:418
#14 0x00007ffff7561a97 in tree_evaluator::visit_statement (
    this=0x7ffff7ddbd38, stmt=...) at /home/jwe/src/octave/src/pt-eval.cc:737
#15 0x00007ffff757cd56 in tree_statement::accept (this=0xd128a0, tw=...)
    at /home/jwe/src/octave/src/pt-stmt.cc:151
#16 0x00007ffff7561c5b in tree_evaluator::visit_statement_list (
    this=0x7ffff7ddbd38, lst=...) at /home/jwe/src/octave/src/pt-eval.cc:773
#17 0x00007ffff757d0be in tree_statement_list::accept (this=0xbd25d0, tw=...)
    at /home/jwe/src/octave/src/pt-stmt.cc:215
#18 0x00007ffff756207c in tree_evaluator::visit_try_catch_command (
    this=0x7ffff7ddbd38, cmd=...) at /home/jwe/src/octave/src/pt-eval.cc:889
#19 0x00007ffff7563264 in tree_try_catch_command::accept (this=0x7f5dd0,
    tw=...) at /home/jwe/src/octave/src/pt-except.cc:69
#20 0x00007ffff7561979 in tree_evaluator::visit_statement (
    this=0x7ffff7ddbd38, stmt=...) at /home/jwe/src/octave/src/pt-eval.cc:707
#21 0x00007ffff757cd56 in tree_statement::accept (this=0x7f5e20, tw=...)
    at /home/jwe/src/octave/src/pt-stmt.cc:151
#22 0x00007ffff7561c5b in tree_evaluator::visit_statement_list (
    this=0x7ffff7ddbd38, lst=...) at /home/jwe/src/octave/src/pt-eval.cc:773
---Type <return> to continue, or q <return> to quit---
#23 0x00007ffff757d0be in tree_statement_list::accept (this=0xbd4830, tw=...)
    at /home/jwe/src/octave/src/pt-stmt.cc:215
#24 0x00007ffff756077b in tree_evaluator::visit_simple_for_command (
    this=0x7ffff7ddbd38, cmd=...) at /home/jwe/src/octave/src/pt-eval.cc:360
#25 0x00007ffff7569e4e in tree_simple_for_command::accept (this=0x7f5c20,
    tw=...) at /home/jwe/src/octave/src/pt-loop.cc:115
#26 0x00007ffff7561979 in tree_evaluator::visit_statement (
    this=0x7ffff7ddbd38, stmt=...) at /home/jwe/src/octave/src/pt-eval.cc:707
#27 0x00007ffff757cd56 in tree_statement::accept (this=0xb7f490, tw=...)
    at /home/jwe/src/octave/src/pt-stmt.cc:151
#28 0x00007ffff7561c5b in tree_evaluator::visit_statement_list (
    this=0x7ffff7ddbd38, lst=...) at /home/jwe/src/octave/src/pt-eval.cc:773
#29 0x00007ffff757d0be in tree_statement_list::accept (this=0x854090, tw=...)
    at /home/jwe/src/octave/src/pt-stmt.cc:215
#30 0x00007ffff74dc594 in octave_user_function::do_multi_index_op (
    this=0x6b4080, nargout=0, args=..., lvalue_list=0x0)
    at /home/jwe/src/octave/src/ov-usr-fcn.cc:476
#31 0x00007ffff74dbe4a in octave_user_function::subsref (this=0x6b4080,
    type=..., idx=..., nargout=0, lvalue_list=0x0)
    at /home/jwe/src/octave/src/ov-usr-fcn.cc:326
#32 0x00007ffff74dbd38 in octave_user_function::subsref (this=0x6b4080,
    type=..., idx=..., nargout=0) at /home/jwe/src/octave/src/ov-usr-fcn.cc:309
#33 0x00007ffff74e4530 in octave_value::subsref (this=0x7fffffffd320,
---Type <return> to continue, or q <return> to quit---
    type=..., idx=..., nargout=0) at /home/jwe/src/octave/src/ov.cc:1201
#34 0x00007ffff74e45d8 in octave_value::subsref (this=0x7fffffffd320,
    type=..., idx=..., nargout=0, lvalue_list=0x0)
    at /home/jwe/src/octave/src/ov.cc:1212
#35 0x00007ffff7566d08 in tree_index_expression::rvalue (this=0xd43520,
    nargout=0, lvalue_list=0x0) at /home/jwe/src/octave/src/pt-idx.cc:407
#36 0x00007ffff7566457 in tree_index_expression::rvalue (this=0xd43520,
    nargout=0) at /home/jwe/src/octave/src/pt-idx.cc:277
#37 0x00007ffff7566f62 in tree_index_expression::rvalue1 (this=0xd43520,
    nargout=0) at /home/jwe/src/octave/src/pt-idx.cc:418
#38 0x00007ffff7561a97 in tree_evaluator::visit_statement (
    this=0x7ffff7ddbd38, stmt=...) at /home/jwe/src/octave/src/pt-eval.cc:737
#39 0x00007ffff757cd56 in tree_statement::accept (this=0xbf3a80, tw=...)
    at /home/jwe/src/octave/src/pt-stmt.cc:151
#40 0x00007ffff7561c5b in tree_evaluator::visit_statement_list (
    this=0x7ffff7ddbd38, lst=...) at /home/jwe/src/octave/src/pt-eval.cc:773
#41 0x00007ffff757d0be in tree_statement_list::accept (this=0xc567b0, tw=...)
    at /home/jwe/src/octave/src/pt-stmt.cc:215
#42 0x00007ffff73f9980 in main_loop ()
    at /home/jwe/src/octave/src/toplev.cc:573
#43 0x00007ffff73b2be7 in octave_main (argc=6, argv=0x7fffffffda58, embedded=0)
    at /home/jwe/src/octave/src/octave.cc:935
#44 0x00000000004008a9 in main (argc=6, argv=0x7fffffffda58)
---Type <return> to continue, or q <return> to quit---
    at /home/jwe/src/octave/src/main.c:35


John W. Eaton <jwe>
Group administrator

 

(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 rik5 (Posted a comment)
  • -email is unavailable- added by cdf (Posted a comment)
  • -email is unavailable- added by jwe (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 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-08-02 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2011-12-19 rik5 Summaryfunction in demo block leads to crash function in %!demo block leads to crash
    2011-08-11 jwe Dependencies- Depends on bugs #32843

    Back to the top

    Powered by Savane 3.13-aa77.
    Corresponding source code