bugGNU Octave - Bugs: bug #56385, operations don't compose

 
 

bug #56385: operations don't compose

Submitter:  None
Submitted:  Fri 24 May 2019 11:04:55 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Regression
Status:  Fixed Assigned to:  None
Originator Name:  JD Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 5.1.0
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 30 May 2019 09:30:21 PM UTC, comment #6: 

The same problem also happens for the method `horzcat`. This can be checked by adding to the previously attached class the following method (inside myFavoriteDouble.m)


    function result = horzcat(this, that)
        result = [double(this), double(that)];
    end


The following command then produces no output:


octave:1> [myFavDouble(1)+myFavDouble(2), myFavDouble(1)+myFavDouble(3)]


For more elaborated classes, it seems that this problem of failing to return an object can cause a segmentation fault, leading octave to quit. Namely I observed the following error:


warning: error caught while executing handle class delete method:
can't perform indexing operations for <unknown type> type
fatal: caught signal Segmentation fault -- stopping myself...
Segmentation fault


I could try to add another comment for every method I encounter which displays this behavior, but that would certainly not be exhaustive. Maybe it would be safer to test systematically every method that can be overloaded in a classdef for stability under various compositions?

Anonymous
Thu 30 May 2019 05:23:37 PM UTC, comment #5: 

Actually, it seems this problem has not been totally fixed for all functions... With the attached slightly augmented MyFavoriteDouble class, I recover the same issue:


octave:1> mex myFavDouble_mex.cpp
octave:2> a = myFavDouble(2)

a =

2.000000

octave:3> b = myFavDouble(3)

b =

3.000000

octave:4> a:b
ans =

   2   3

octave:5> b:a
ans = [](1x0)
octave:6> myFavDouble(2):myFavDouble(3)
octave:7> myFavDouble(3):myFavDouble(2)
octave:8> c=myFavDouble(2):myFavDouble(3)
error: value on right hand side of assignment is undefined
octave:8> d=myFavDouble(3):myFavDouble(2)
error: value on right hand side of assignment is undefined


Results are properly assigned when calling the function `colon` with pre-existing objects. But no results are assigned when the method `colon` is called with new objects. We would expect the last four lines to reproduce the results of lines 4 and 4... (running octave 6.0.0)

(file #47005)

Anonymous
Sat 25 May 2019 02:05:33 PM UTC, comment #4: 

Alright, will do. Thanks again!

Anonymous
Sat 25 May 2019 11:31:53 AM UTC, comment #3: 

Yes please, smaller bug reports are easier to handle.

Can you check https://wiki.octave.org/Classdef before opening new reports to avoid duplicates.

Kai Torben Ohlhus <siko1056>
Group Member
Sat 25 May 2019 11:15:24 AM UTC, comment #2: 

Awesome, I could check that this problem is fixed in Octave 6. Thanks a lot for looking into that!

I do have other troubles, however, when using a test suite in Octave 6 - which I didn't have with Octave 4.2. Should I open another report for that?

Anonymous
Sat 25 May 2019 01:31:34 AM UTC, comment #1: 

Thank you for your thorough bug report. I can confirm the error in Octave 5.1 (including the stable branch which will become Octave 5.2), but this appears to be fixed already in Octave 6 (development version, not yet released).


>> mex myFavDouble_mex.cpp
>> e = plus (myFavDouble (1), myFavDouble (2))

d =

3.000000


The changes to the classdef code are probably too substantial to backport to Octave 5.2, so this will likely remain unfixed until Octave 6 is officially released.

If classdef features are important to you, please consider evaluating Octave 6 in development, if that's feasible for you, and help test or report other classdef problems so they can be fixed for the Octave 6 release.

Mike Miller <mtmiller>
Group Member
Fri 24 May 2019 11:04:55 PM UTC, original submission:  

When working with the very simple class 'MyFavoriteDouble' (c.f. https://github.com/jdbancal/MyFavoriteDouble ) the following happens:


GNU Octave, version 5.1.0
Copyright (C) 2019 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-pc-linux-gnu".

Additional information about Octave is available at https://www.octave.org.

Please contribute if you find this software useful.
For more information, visit https://www.octave.org/get-involved.html

Read https://www.octave.org/bugs.html to learn how to submit bug reports.
For information about changes from previous versions, type 'news'.

octave:1> a=myFavDouble(1)

a =

1.000000

octave:2> b=myFavDouble(2)

b =

2.000000

octave:3> c=a+b

c =

3.000000

octave:4> d=plus(a,b)

d =

3.000000

octave:5> e=plus(myFavDouble(1), myFavDouble(2))
error: value on right hand side of assignment is undefined
octave:5>


Clearly:

  • the class 'myFavDouble' is well defined (it is a very simple classdef) and its constructor works well and produces a result
  • the function 'plus' works and produces a result
  • but it is not possible to combine both functions in one shot: octave complains that he receives nothing from 'plus(myFavDouble(1), myFavDouble(2))' to assign to the variable 'e'. What we would expect here is to get the output "d=3.000000" instead of an error.


This constitutes a regression because it works seemlessly on Octave 4.2.2 (but already not anymore on Octave 4.4.1, haven't tested 4.4.0). It also constitutes a incompatibility with matlab, because matlab doesn't have this problem (even on the latest versions; tested on matlab 2018b).

To reproduce this bug, download the above code, type `mex MyFavDouble_mex` in Octave, and you are ready to test the above commands.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #47005:  MyFavoriteDouble.tar.gz added by None (38KiB - application/gzip)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by None (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-05-30 None Attached File- Added MyFavoriteDouble.tar.gz, #47005
    2019-05-25 mtmiller StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code