bugGNU Octave - Bugs: bug #41945, Segfault when subsasgn returns...

 
 

bug #41945: Segfault when subsasgn returns nothing in user-defined class

Submitter:  Andreas Weber <andy1978>
Submitted:  Mon 24 Mar 2014 03:45:48 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 3.8.1 Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 25 Mar 2014 10:25:53 AM UTC, comment #5: 

Stefan, thank you for your patch. I've applied it to default: http://hg.savannah.gnu.org/hgweb/octave/rev/75467145096f

-- Andy

Andreas Weber <andy1978>
Group Member
Mon 24 Mar 2014 10:51:10 PM UTC, comment #4: 

The segfault in function occurs octave_user_function::subsasgn_optimization_ok, because ret_list is NULL (since there's output argument to subsasgn). Using 'function out = subsasgn' also triggers a segfault - in this case param_list is NULL.

Patch is attached or can be found here (with some other ones): bookmark nkf-ready


(file #31030)

Stefan Mahr <dac922>
Mon 24 Mar 2014 10:05:56 PM UTC, comment #3: 

Yes, I made a typo in subsasgn. Now it segfaults too. Sorry.

Stefan Mahr <dac922>
Mon 24 Mar 2014 09:23:15 PM UTC, comment #2: 

segfault here also with default 54a1e95365e1, configured without jit. GDB backtrace below.

I figured out that it only segfaults when optimize_subsasgn_calls is enabled.


Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffdb702700 (LWP 2359)]
0x00007ffff6cc19c6 in std::list<tree_decl_elt*, std::allocator<tree_decl_elt*> >::begin (this=0x0)
    at /usr/include/c++/4.7/bits/stl_list.h:749
749              { return const_iterator(this->_M_impl._M_node._M_next); }
(gdb) bt
#0  0x00007ffff6cc19c6 in std::list<tree_decl_elt*, std::allocator<tree_decl_elt*> >::begin (this=0x0)
    at /usr/include/c++/4.7/bits/stl_list.h:749
#1  0x00007ffff6cbc792 in std::list<tree_decl_elt*, std::allocator<tree_decl_elt*> >::size (this=0x0)
    at /usr/include/c++/4.7/bits/stl_list.h:855
#2  0x00007ffff6cb87ce in octave_base_list<tree_decl_elt*>::size (this=0x0)
    at ../../octave-src/liboctave/util/base-list.h:44
#3  0x00007ffff6cb8914 in octave_base_list<tree_decl_elt*>::length (this=0x0)
    at ../../octave-src/liboctave/util/base-list.h:45
#4  0x00007ffff6d57680 in octave_user_function::subsasgn_optimization_ok (this=0x9a5b30)
    at ../../octave-src/libinterp/octave-value/ov-usr-fcn.cc:694
#5  0x00007ffff6c7b23c in octave_class::subsasgn_common (this=0xd6e960, obj=..., type=..., idx=..., rhs=...)
    at ../../octave-src/libinterp/octave-value/ov-class.cc:594
#6  0x00007ffff6c7ad4e in octave_class::subsasgn (this=0xd6e960, type=..., idx=..., rhs=...)
    at ../../octave-src/libinterp/octave-value/ov-class.cc:530
#7  0x00007ffff6d62116 in octave_value::subsasgn (this=0x99b9a0, type=..., idx=..., rhs=...)
    at ../../octave-src/libinterp/octave-value/ov.cc:1387
#8  0x00007ffff6d622d8 in octave_value::assign (this=0x99b9a0, op=octave_value::op_asn_eq, type=..., idx=..., rhs=...)
    at ../../octave-src/libinterp/octave-value/ov.cc:1429
#9  0x00007ffff713484e in symbol_table::symbol_record::symbol_record_rep::assign (this=0xd60170,
    op=octave_value::op_asn_eq, type=..., idx=..., value=..., context=18446744073709551615)
    at ../../octave-src/libinterp/corefcn/symtab.h:231
#10 0x00007ffff713494f in symbol_table::symbol_record::assign (this=0x7fffdb701a68, op=octave_value::op_asn_eq,
    type=..., idx=..., value=..., context=18446744073709551615) at ../../octave-src/libinterp/corefcn/symtab.h:547
#11 0x00007ffff7134490 in octave_lvalue::assign (this=0x7fffdb701a60, op=octave_value::op_asn_eq, rhs=...)
    at ../../octave-src/libinterp/corefcn/oct-lvalue.cc:40
#12 0x00007ffff6dbde16 in tree_simple_assignment::rvalue1 (this=0xd71be0)
    at ../../octave-src/libinterp/parse-tree/pt-assign.cc:116
#13 0x00007ffff6dcc46e in tree_evaluator::visit_statement (this=0x7ffff7903e38, stmt=...)
    at ../../octave-src/libinterp/parse-tree/pt-eval.cc:753
#14 0x00007ffff6dee3e2 in tree_statement::accept (this=0xd71c20, tw=...)
    at ../../octave-src/libinterp/parse-tree/pt-stmt.cc:178
#15 0x00007ffff6dcc6e8 in tree_evaluator::visit_statement_list (this=0x7ffff7903e38, lst=...)
    at ../../octave-src/libinterp/parse-tree/pt-eval.cc:803
#16 0x00007ffff6deea2e in tree_statement_list::accept (this=0x9a0990, tw=...)
    at ../../octave-src/libinterp/parse-tree/pt-stmt.cc:291
#17 0x00007ffff72286c3 in main_loop () at ../../octave-src/libinterp/corefcn/toplev.cc:593
#18 0x00007ffff68d8c20 in octave_execute_interpreter () at ../../octave-src/libinterp/octave.cc:888
#19 0x00007ffff7aa03ea in octave_cli_thread::run (this=0x7fffffffc390) at ../../octave-src/libgui/src/octave-gui.cc:76
#20 0x00007ffff2a72d0b in ?? () from /usr/lib/x86_64-linux-gnu/libQtCore.so.4
#21 0x00007ffff454eb50 in start_thread (arg=<optimized out>) at pthread_create.c:304
#22 0x00007ffff42990ed in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#23 0x0000000000000000 in ?? ()


Andreas Weber <andy1978>
Group Member
Mon 24 Mar 2014 04:14:06 PM UTC, comment #1: 

No segfault with dev (5cf9a02732b6)


octave:1> x=myclass(3)
This is myclass with value=123
octave:2> x(4)=5
error: invalid class assignment
error: assignment failed, or no method for 'class = scalar'


Stefan Mahr <dac922>
Mon 24 Mar 2014 03:45:48 PM UTC, original submission:  

When playing with user-defined classes I get a segfault when there is no return from @myclass/subasgn


function r = myclass (a)
  tmp.value = 123;
  r = class (tmp, "myclass");
endfunction

function display(c)
  fprintf("This is myclass with value=%d\n", c.value);
endfunction

function subsasgn (val, idx, rhs)
  val
  idx
  rhs
endfunction

octave:1> x=myclass(3)
This is myclass with value=123
octave:2> x(4)=5
panic: Segmentation fault -- stopping myself...
attempting to save variables to 'octave-workspace'...
save to 'octave-workspace' complete
Speicherzugriffsfehler


I think implementing subsasgn in a user-defined class without return value (like my example above) doesn't make sense but nevertheless octave shouldn't segfault.

-- Andy

Andreas Weber <andy1978>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #31030:  subsasgn.diff added by dac922 (899B - text/x-patch)
file #31024:  myclass.tar.gz added by andy1978 (355B - application/x-gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jordigh (Updated the item)
  • -email is unavailable- added by dac922 (Posted a comment)
  • -email is unavailable- added by andy1978 (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
    2014-03-28 jordigh StatusNone Fixed
    2014-03-25 andy1978 Open/ClosedOpen Closed
    2014-03-24 dac922 Attached File- Added subsasgn.diff, #31030
    2014-03-24 andy1978 Attached File- Added myclass.tar.gz, #31024

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code