bugGNU Octave - Bugs: bug #55758, classdef: delete method causes...

 
 

bug #55758: classdef: delete method causes temporaries to be deleted before use

Submitter:  Mike Miller <mtmiller>
Submitted:  Thu 21 Feb 2019 11:16:30 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
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
   

Jump to the original submission

Fri 12 Feb 2021 02:52:52 PM UTC, comment #6: 

That file is installed for me with the Windows installer for 6.1.90:
"C:\Program Files\GNU Octave\Octave-6.1.90\mingw64\share\octave\6.1.90\etc\tests\fixed\bug-55758\class_bug_55758.m"

And the test suite passed for me.

We recently tried to speed up some portions of the load_path class. Maybe something is missing now after a directory change.
But I don't know how it works for me and fails for you. That sounds more like a threading issue.
The file browser in the GUI is flashing rapidly for me while the test suite is running. Maybe that causes issues with de-syncing current directories?

Maybe best open a new bug report for this issue.

Markus Mützel <mmuetzel>
Group administrator
Fri 12 Feb 2021 01:36:17 PM UTC, comment #5: 

In mxe-octave, 6.1.91, running the test suite I get a fail in bug-55758.tst

!!!!! test failed
'class_bug_55758' undefined near line 6, column 6

John Donoghue <lostbard>
Group Member
Wed 17 Apr 2019 06:06:14 PM UTC, comment #4: 

OK, closing as fixed.

John W. Eaton <jwe>
Group administrator
Tue 09 Apr 2019 03:12:38 AM UTC, comment #3: 

Ok, may be an issue in my code, this might be fixed. You can close it as fixed if you want and I can come back later if there is still a problem. It will take a little refactoring.

Basically, I have a constructor that depends on values initialized in C++ code. The C++ function returns a second instance of the object, which overwrites the original.


classdef myobject < handle
  methods
    function obj = myobject (value, id)
      if (nargin == 1)
        obj = __helper_function__ (value);
      else
        obj.id = id;
      endif


This created two instances of the object, and when the first one was deleted, it hadn't been fully constructed, so it looked like properties of the object were missing. I'll rewrite all of this so a second instance of the object doesn't need to be created.

Mike Miller <mtmiller>
Group Member
Tue 09 Apr 2019 12:37:13 AM UTC, comment #2: 

Something still does not work for me, I'll try to come back with a minimal example that demonstrates the remaining errors I'm seeing.

Mike Miller <mtmiller>
Group Member
Fri 15 Mar 2019 07:30:27 PM UTC, comment #1: 

I pushed the following changset:

http://hg.savannah.gnu.org/hgweb/octave/rev/ab9520ef3895

In it, I added tests based on what you show below and they are passing for me now.

John W. Eaton <jwe>
Group administrator
Thu 21 Feb 2019 11:16:30 PM UTC, original submission:  

Attached is a classdef handle class example with a delete method. With this example class, the following shows that temporary objects are deleted by the interpreter before they are passed into the functions that they are arguments for.


>> class_delete_method (5).value
>> class_delete_method (5)(1)
>> disp (class_delete_method (5))
<object class_delete_method>
>> size (class_delete_method (5))
>> numel (class_delete_method (5))


The 'delete' destructor is called properly, it does have access to the class properties when it is deleted, but the object is deleted by the interpreter before it is placed on the call stack.

Removing the 'delete' method from the class definition restores the normal behavior of how I would expect temporaries to work.

Because of the major rework of the call stack on the default branch recently, I figured this would be a good candidate for fixing for Octave 6.

I also think the attached class is a good start for some BIST tests for the delete method.

This was originally discussed in comments on bug #53844, so marking as confirmed.

Mike Miller <mtmiller>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #46331:  class_delete_method.m added by mtmiller (535B - text/x-objcsrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  •  

    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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-04-17 jwe StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-03-15 jwe StatusConfirmed Ready For Test
    2019-02-21 mtmiller Carbon-CopyRemoved 80942 -
    2019-02-21 mtmiller Attached File- Added class_delete_method.m, #46331

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code