patchGNU Octave - Patches: patch #8152, classdef: Fix crash when indexing...

 
 

patch #8152: classdef: Fix crash when indexing classdef object with empty parentheses.

Submitter:  Philipp Kutin <pkutin>
Submitted:  Mon 05 Aug 2013 11:19:35 AM UTC
   
 
Category:  None Priority:  5 - Normal
Status:  Done Privacy:  Public
Assigned to:  None Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 27 Apr 2015 03:44:23 PM UTC, comment #5: 

I filed a bug report about the Matlab incompatibility of not copying the object over when using empty indexing '()'.  See https://savannah.gnu.org/bugs/index.php?44940.

Rik <rik5>
Group administrator
Sun 26 Apr 2015 04:21:52 PM UTC, comment #4: 

I checked in Matlab and indeed, empty indexing should return the object and not throw an error:


>> a = foo ()

a =

  foo handle

  Properties:
     child: []
    parent: []


>> b = a()

b =

  foo handle

  Properties:
     child: []
    parent: []


>> whos
  Name      Size            Bytes  Class    Attributes

  a         1x1               112  foo
  b         1x1               112  foo



Carnë Draug <carandraug>
Group Member
Sat 25 Apr 2015 05:26:49 PM UTC, comment #3: 

No problem.  I'm going to mark this as done and close it.  If the segfaults return we can investigate further.

Rik <rik5>
Group administrator
Sat 25 Apr 2015 04:54:47 PM UTC, comment #2: 

I saw your changeset 20125:274b52724931 and to me it looks like what I intended back then: to prevent "something bad" happening (on reaching "Array<cdef_object> ires = array.index (iv, auto_add);"?) when the index vector is empty.

> Another consideration, shouldn't null indexing just return the object itself rather than generate an error?


Unfortunately I can't test this, since I don't have access to MATLAB anymore.

Philipp Kutin <pkutin>
Tue 21 Apr 2015 04:24:12 PM UTC, comment #1: 

@Philipp: Could you re-generate your patch against a more recent version of the Mercurial source tree?  I used hg import and the patch applied, but at a fuzzy offset of 450 lines.  And when I went to test I still got a segfault so I don't think the patch applied cleanly.

Test object in foo.m


classdef foo < handle
  properties
    child
    parent
  end
end


Test code


x = foo ();
x.child = 23;
x()


Another consideration, shouldn't null indexing just return the object itself rather than generate an error?

For matrices this is the case


x = 1:10;
y = x()
y =

    1    2    3    4    5    6    7    8    9   10



Rik <rik5>
Group administrator
Mon 05 Aug 2013 11:19:35 AM UTC, original submission:  
  • ov-classdef.cc: check whether 'ival' is empty and generate an error in that case instead of continuing and crashing.

--

The crash is easy to reproduce: just create any classdef object, e.g. "o=TestClass()", then do "o()". Btw, the parent commit won't make sense -- it's my own (in classdef-pk), changing .hgignore for my setup (build subdir inside octave dir). But as far as I can see, "hg import" is pretty liberal...

Philipp Kutin <pkutin>

 

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

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

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 pkutin (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 logged-in users can vote.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-04-25 rik5 StatusNone Done
        Open/ClosedOpen Closed
    2013-08-05 pkutin Attached File- Added classdef-fix-crash-empty-idxparen.patch, #28762

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code