bugGNU Octave - Bugs: bug #32296, matlabbatch: equivalent subscript...

 
 

bug #32296: matlabbatch: equivalent subscript assignments produce unequal results

Submitter:  Volkmar Glauche <glauche>
Submitted:  Sun 30 Jan 2011 09:16:59 PM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Mon 04 Dec 2023 05:46:52 PM UTC, comment #11: 

behavior unchanged in Octave 9.0.1 (hg id: 14cb31ec0251)

Nicholas Jankowski <nrjank>
Group Member
Fri 30 Jul 2021 03:54:00 PM UTC, comment #10: 

The issue is still present in Octave 6.3.0 based on the same assessment as comment #9

Nicholas Jankowski <nrjank>
Group Member
Sat 19 Nov 2016 02:35:23 PM UTC, comment #9: 

This issue seems to still be present in Octave 4.2.0.

(The test script from the from the original submission still returns "false", when used together with the files from comment #4.)

Hartmut <hardy>
Tue 15 Jul 2014 02:55:56 PM UTC, comment #8: 

Using the following changes to cfg_callbuiltin.m and helper functions oct_findfield.m and oct_fixsubs.m I was able to run the simple batch file attached (test.m).

I'm sure it requires testing but I think the way Octave's builtin() is implemented can be worked around with this approach.

Stanislaw Adaszewski <sadaszew>
Tue 21 Jan 2014 01:59:50 PM UTC, comment #7: 

Thanks for proofing, trying again:


> x = cfg_repeat ();
> y = cfg_repeat ();
> isequal (x, y)
ans =  1
> a = cfg_exbranch ();
> x.values{1} = a;
> y.values{1} = cfg_exbranch ();
> isequal (x, y)
ans =  1
> a.tag
ans = generic
> a.tag = "ex";
> x.values{1} = a;
> x.values{1}.tag
error: class has no member 'tag'
error: called from:
error:   /.../cfg_callbuiltin.m at line 10, column 18
error:   /.../@cfg_repeat/subsref.m at line 68, column 34
> y.values{1} = cfg_exbranch ();
> y.values{1}.tag = "ex";
> isequal (x, y)
ans = 0


Mike Miller <mtmiller>
Group Member
Tue 21 Jan 2014 08:28:09 AM UTC, comment #6: 

The code excerpt given is from a batch configuration and job management system used e.g. by Statistical Parametric Mapping (SPM), a MATLAB software that is used widely in brain imaging and data analysis. While development is focused on MATLAB, SPM developers would like to support Octave as well. Most of the algorithms implemented in SPM run fine on Octave,  but the batch system as a major part of the command line user interface to SPM does not.

I understand that there seems to be an incompatibility between MATLAB and Octave when dispatching to the correct subsasgn/subsref methods for @-objects. MATLAB also has difficulties there, which have been resolved by the cfg_callbuiltin.m function.

For SPM, it would be necessary to get the same subsasgn/subsref behaviour in both MATLAB and Octave. If this can't be fixed easily in Octave itself, I would be open to suggestions to work around this problem.

Best, Volkmar

PS@Mike:

your comment #5 seems to be truncated on the web page for this bug compared to the email.


Volkmar Glauche <glauche>
Tue 21 Jan 2014 07:06:54 AM UTC, comment #5: 

Yes, the example with the provided class definitions still shows the reported problem in the current development version. Here's another way of looking at the symptom:


> x = cfg_repeat ();
> y = cfg_repeat ();
> isequal (x, y)
ans =  1
> a = cfg_exbranch ();
> x.values{1} = a;
> y.values{1} = cfg_exbranch ();
> isequal (x, y)
ans =  1
> a.tag
ans = generic
> a.tag = "ex";
> x.values{1} = a;
> x.values{1}.tag
error: class has no member 'tag'
error: called from:
error:   /.../cfg_callbuiltin.m at line 10, column 18
error:   /.../@cfg_repeat/subsref.m at line 68, column 34
> y.values{1} = cfg_exbranch ();
> y.values{1}.tag = "ex";
> isequal (x, y)
ans = 0

Mike Miller <mtmiller>
Group Member
Mon 20 Jan 2014 09:28:20 AM UTC, comment #4: 

I've compiled an excerpt from my original project containing the relevant .m files only. See matlabbatch_extract.tgz attached. Although there are multiple classes (cfg_repeat, cfg_exbranch, cfg_branch) derived from cfg_item, all share the same subsasgn/subsref logic.

Things seem to go wrong whenever one of the class subsasgn/subsref methods call cfg_callbuiltin to dispatch subscript reference/assignment calls.

The example code from the original submission still produces this problem in octave 3.6.4.

Steps to test:

1. Unpack matlabbatch_extract.tgz into new folder
2. add this folder to octave's path
3. run the code lines from the original bug submission

cr and cr1 should have the same contents, especially the cfg_exbranch objects in cr.values{1} and cr1.values{1} should have the same contents. cr is the reference object, information is lost when assigning cr1.values{1}.tag.

I did not yet try octave 3.8 or a current developer release, but would be happy to do so if there might be a chance that the problem has been resolved.


(file #30316)

Volkmar Glauche <glauche>
Mon 20 Jan 2014 12:15:02 AM UTC, comment #3: 

It would be nice if there was a simple example pasted or attached to this report to reproduce this error. Setting status to "need info" for now, I don't know how to test if this still affects the current development version.

Mike Miller <mtmiller>
Group Member
Mon 31 Jan 2011 11:17:58 AM UTC, comment #2: 

Calling subsasgn via builtin is actually required by MATLAB to figure out correctly which method to call.
Anecdotally, the way this is done (outside any object method using the static cfg_callbuiltin) works around a problem in MATLAB, where builtin() called from an object method does not determine the correct subsasgn method as well...

Volkmar Glauche <glauche>
Mon 31 Jan 2011 10:48:58 AM UTC, comment #1: 

Jaroslav, I'm copying you on this report because you have worked on this part of Octave much more than I have lately, so I'm hoping you will have some insight here.

It seems that this problem is related to the following change:

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

which was made in response to the following bug report:

https://mailman.cae.wisc.edu/pipermail/help-octave/2009-April/034731.html

The change added a check to see whether octave_value::subsasgn was called from the "builtin" function, and if so, the subsasgn method lookup is skipped.  Maybe this was not the right fix, but it avoided the reported problem.

In your case, the cfg_repeat and cfg_exbranch subsasgns call subsasgn using the "builtin" function, but they should perform the method lookup, and if they do, I think Octave does the right thing for your code.

However, simply removing the check for called_from_builtin in subsasgn brings back the earlier problem.

So I don't know how to solve both problems at the same time.  What is the appropriate check that should be made here to avoid the recursion in one case and to allow the method lookup when it is needed?

John W. Eaton <jwe>
Group administrator
Sun 30 Jan 2011 09:16:59 PM UTC, original submission:  

Using matlabbatch (see bug #32261) objects, the following commands should produce two identical objects cr and cr1:


cr=cfg_repeat;
ce=cfg_exbranch;
ce.tag = 'ex';
cr.values{1}=ce;
cr1=cfg_repeat;
cr1.values{1}=cfg_exbranch;
cr1.values{1}.tag='ex';


The only difference is that the contents of cr.values{1} is created as a separate object in workspace before it is assigned, while the contents of cr1.values{1} is assigned 'on-the-fly'. In MATLAB,


isequal(cr,cr1)


returns true, while octave returns false. Octave should return true as well. As far as I can tell, cr is the correct result, while cr1 is not created correctly.

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 #31720:  cfg_callbuiltin.m added by sadaszew (476B - text/x-objcsrc)
file #31721:  oct_findfield.m added by sadaszew (848B - text/x-objcsrc)
file #31722:  oct_fixsubs.m added by sadaszew (630B - text/x-objcsrc)
file #31723:  test.m added by sadaszew (397B - text/x-objcsrc)
file #30316:  matlabbatch_extract.tgz added by glauche (14KiB - application/x-gtar)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by nrjank (Posted a comment)
  • -email is unavailable- added by hardy (Posted a comment)
  • -email is unavailable- added by sadaszew (Updated the item)
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -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 10 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-12-04 nrjank Operating SystemGNU/Linux Any
    2014-07-15 sadaszew Attached File- Added cfg_callbuiltin.m, #31720
        Attached File- Added oct_findfield.m, #31721
        Attached File- Added oct_fixsubs.m, #31722
        Attached File- Added test.m, #31723
    2014-01-21 mtmiller StatusNeed Info Confirmed
    2014-01-20 glauche Attached File- Added matlabbatch_extract.tgz, #30316
    2014-01-20 mtmiller CategoryNone Octave Function
        StatusNone Need Info
    2011-01-31 jwe Carbon-Copy- Added highegg

    Back to the top

    Powered by Savane 3.13-758e.
    Corresponding source code