octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #34967] Bad behavior of structures with an emp


From: Henrik Alsing Friberg
Subject: [Octave-bug-tracker] [bug #34967] Bad behavior of structures with an empty cell
Date: Fri, 02 Dec 2011 10:30:49 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0

URL:
  <http://savannah.gnu.org/bugs/?34967>

                 Summary: Bad behavior of structures with an empty cell
                 Project: GNU Octave
            Submitted by: hfriberg
            Submitted on: Fri 02 Dec 2011 10:30:48 AM GMT
                Category: Interpreter
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Crash
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: 3.4.2
        Operating System: GNU/Linux

    _______________________________________________________

Details:

The following is an example of a structure that behaves badly when it has an
empty cell within.

val = struct("name", {});


This submission will be a list of examples of this behavior, ending with one
that causes a crash. The problem in all cases is that this particular
structure does not behave as other structures.

*Example 1*
The structure has more fieldnames than fields:

octave:2> length(fieldnames(val))
ans =  1
octave:3> length(val)
ans = 0


*Example 2*
Interpretation terminates once the empty cell is encountered.

octave:4> [1, 2, val.name, 4, 5]
ans =
   1   2


*Example 3*
Any member can be extracted from the structure without errors, but the result
is undefined even for 'val.name' which should be an empty cell.

octave:5> val.blabla
octave:6> val.qwerty
octave:7> ans = val.name
error: value on right hand side of assignment is undefined


Normally you would get these errors

octave:5> ans = struct();
octave:6> ans.blabla
error: structure has no member `blabla'


*Example 4*
>From within an OCT-file, the underlying octave_value of this structure can not
be extracted and causes a segmentation fault with core dump.

Octave_map::const_iterator p1 = arg0.seek( "name" );   
octave_value tmp = arg0.contents( p1 ) (0);


This crash can be avoided by checking the size of 

arg0.contents( p1 ).length()

... but the Octave Manual does not mention this, and I doubt many of us have
implemented that check.




    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?34967>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]