bugGNU Octave - Bugs: bug #32182, data loss in hierarchical objects

 
 

bug #32182: data loss in hierarchical objects

Submitter:  Volkmar Glauche <glauche>
Submitted:  Wed 19 Jan 2011 09:03:46 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  highegg
Originator Name:  Open/Closed:  * Closed
Release:  * dev Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sat 22 Jan 2011 12:56:05 PM UTC, comment #2: 

Well, frankly, the inheritance model for the old style classes is a steaming pile of crap and nowadays you can't even get a decent doc from matlab telling us how it should be done.

If the new-style classes were at least on the way, I'd simply drop the support. Octave never worked correctly in that regard anyway.

That being said, I believe this patch solves the issue:
http://hg.savannah.gnu.org/hgweb/octave/rev/b83162e8f402

There is a separate problem with display only succeeding once, but I believe that's orthogonal to this issue. I'll make it a separate bug.
Nevertheless, inspecting the class's fields with aid of struct() suggests that it works as intended now, so I'm closing this.

Jaroslav Hajek <highegg>
Sat 22 Jan 2011 09:11:00 AM UTC, comment #1: 

Jaroslav, could you please take a look at this problem?  There seems to be some issue with reference counting here, as the call to the manipulate method is somehow changing the size of item.baseobj.val (a cell array of objects).  I'm not yet seeing where that is happening and since you've done a lot of work with indexing and assignment for classes, maybe you will spot it sooner than I can.

I'm not sure whether it will give you some clues or help with debugging, but rewriting the @derivobj/manipulate.m function from


function item = manipulate(item)

% manipulate the inherited 'val' field of a derivobj.

for k = 1:numel(item.baseobj.val)
    item.baseobj.val{k} = manipulate(item.baseobj.val{k});
end


to

+vertabim+
function item = manipulate(item)

% manipulate the inherited 'val' field of a derivobj.
tmp = cell (1, numel(item.baseobj.val));
for k = 1:numel(item.baseobj.val)
    tmp{k} = manipulate(item.baseobj.val{k});
end
item.baseobj.val = tmp;
-verbatim-

avoids the problem for me.

John W. Eaton <jwe>
Group administrator
Wed 19 Jan 2011 09:03:46 PM UTC, original submission:  

I have got a hierarchy of object classes:
baseobj
derivobj  - derived from baseobj
deriv2obj - derived from derivobj

baseobj and derivobj define a method manipulate(). In baseobj, this method assigns a random number to the .val property. In derivobj/deriv2obj, it calls a manipulate() method on each member of a cell array .val. While manipulate() operates correctly on derivobj objects, it crashes on deriv2obj objects:


d1 = derivobj;
d1.val = {baseobj baseobj};
d1m = manipulate(d1);
d2 = deriv2obj;
d2.val = {baseobj baseobj};
d2m = manipulate(d2);
error: manipulate: A(I): index out of bounds; value 2 out of bound 1
error: called from:
error:   /home/volkmar/octave/@derivobj/manipulate.m at line 6, column 26


The error occurs in the for loop in @derivobj/manipulate, when trying to access the .val field entries in a deriv2obj. The same code works perfectly for derivobj objects.

Volkmar Glauche <glauche>

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #22459:  deriv2obj.tgz added by glauche (3KiB - application/x-compressed-tar)

 

Depends on the following items: None found

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by highegg (Updated the item)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by jwe
  • -email is unavailable- added by glauche (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-04-12 dbateman Dependencies- bugs #33014 is dependent
    2011-01-22 highegg StatusNone Fixed
        Open/ClosedOpen Closed
    2011-01-22 highegg Assigned toNone highegg
    2011-01-22 jwe Carbon-Copy- Added highegg
    2011-01-19 glauche Attached File- Added deriv2obj.tgz, #22459

    Back to the top

    Powered by Savane 3.14-79a4.
    Corresponding source code