bugGNU Octave - Bugs: bug #44643, classdef handle object can go into...

 
 

bug #44643: classdef handle object can go into an recursive loop with isequal(obj1,obj2) if both are self-referential

Submitted by:  jsh <jsh>
Submitted on:  Fri 27 Mar 2015 07:50:45 AM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: ConfirmedAssigned to: None
Originator Name: Open/Closed: Open
Release: 4.0.0Operating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Wed 29 Jun 2016 02:52:21 AM UTC, comment #3:

I don't think this is trivial.

The issue is that

is assigning handles to the objects, rather than assigning values. That gives rise to a closed loop: a.parent.child = a. Naively walking that structure as a tree gives the loop.

If we repeat that with

then to compare isequal(a, c), we need _isequal_ to learn the actual structure (since we can't simply rely on checking that the "rep" is the same, which was my first thought).

It isn't even clear what _isequal_(a,c) should be. Either "true" or "false" is self-consistent.

Perhaps we can still walk the tree keeping track of the rep values we have seen. If one finds the n'th rep again and the other also finds the n'th rep at the same point, we report success without the recursive call. If one finds the n'th rep again and the other doesn't, we return false.

That will consume a huge amount of memory when comparing large trees. It would be helped slightly if a persistent variable is used, so we don't need the list of visited nodes in each stack frame.

I'm reassigning this from "crash" to "Matlab compatibility". (There is still no way to distinguish a very dangerous silent "incorrect result" from something that simply reports an error.)

Lachlan Andrew <lachlan>
Project Member
Tue 02 Jun 2015 04:43:59 PM UTC, comment #2:

Retagging release from 4.0.0-rc2 to 4.0.0.

John W. Eaton <jwe>
Project Administrator
Mon 30 Mar 2015 05:46:31 AM UTC, comment #1:

Confirmed. This looks like something rather trivial in _isequal_.m.

Rik <rik5>
Project Administrator
Fri 27 Mar 2015 07:50:45 AM UTC, original submission:

When using a handle class object with properties that define child/parent relations isequal comparison goes into a recursive loop when comparing an instance with itself. For example, define the class foo:

And create two instances one child and one parent:

isequal(a,b) works fine and returns zero while isequal(a,a) or isequal(b,b) goes into a recursive loop (unlike Matlab which returns 1).

jsh <jsh>

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by lachlan (Posted a comment)
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by jordigh (Updated the item)
  • -unavailable- added by jsh (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 29 Jun 2016 02:52:21 AM UTClachlanItem GroupSegfault, Bus Error, etc.=>Matlab Compatibility
      Summaryclassdef handle object can go into an recursive loop with isequal(obj,obj)=>classdef handle object can go into an recursive loop with isequal(obj1,obj2) if both are self-referential
    Tue 02 Jun 2015 04:43:59 PM UTCjweRelease4.0.0-rc2=>4.0.0
    Mon 30 Mar 2015 05:46:31 AM UTCrik5StatusNone=>Confirmed
    Fri 27 Mar 2015 07:11:10 PM UTCjordighItem GroupMatlab Compatibility=>Segfault, Bus Error, etc.

    Back to the top


    Powered by Savane 3.1-cleanup1