bugGNU Octave - Bugs: bug #64704, VM error with chained indexing...

 
 

bug #64704: VM error with chained indexing expression

Submitter:  Arun Giridhar <arungiridhar>
Submitted:  Thu 21 Sep 2023 12:47:54 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
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
   

Sun 01 Oct 2023 04:41:02 PM UTC, comment #4: 

No complaints from CI. Closing as fixed.

Arun Giridhar <arungiridhar>
Group Member
Sat 23 Sep 2023 03:25:45 PM UTC, comment #3: 

Thanks. Looks good to me. Pushed to https://hg.savannah.gnu.org/hgweb/octave/rev/dfcbe2dcd8e2

Ready for test

Arun Giridhar <arungiridhar>
Group Member
Sat 23 Sep 2023 12:24:06 AM UTC, comment #2: 

I've made three patches to address three bug reports. Testsuite runs fine. I applied them in the following order.

https://savannah.gnu.org/bugs/index.php?64702 (octave_32320.patch)
https://savannah.gnu.org/bugs/index.php?64703 (octave_32321.patch)
https://savannah.gnu.org/bugs/?64704 (octave_32322.patch, this bug)

Petter <petter>
Sat 23 Sep 2023 12:17:37 AM UTC, comment #1: 


VM Fix '[]' as rhs in chained subassigns (bug #64704)

Using the constant '[]' as rhs in e.g. 'a(ii) = b(ii) = []' made
'[]' lose its deleting abilities on 'a' due to call to storable().

* libinterp/parse-tree/pt-bytecode-vm.cc: New opcode DUP_MOVE
* libinterp/parse-tree/pt-bytecode-walk.cc: Use DUP_MOVE instead of slots
                                            and FORCE_ASSIGN
* libinterp/parse-tree/pt-bytecode.h: Opcode enum
* test/compile/bytecode_subsasgn.m: Update tests


Please see attached patch.

It seems like a call to 'make_storable_value()' on the '[]' constant makes it lose its magic capabilities.

(file #55160)

Petter <petter>
Thu 21 Sep 2023 12:47:54 PM UTC, original submission:  

The VM has some difficulty with evaluating chained indexing expressions as in the last line of this example. This minimum reproducer was distilled from production code where this kind of indexing was happening.


  lst = rand (285, 16);
  areas = rand (285, 1);
  ii = true (285, 1);
  ii([18 33 34 38 45 57 74 91 130 154 176 213 246 279]) = 0;
  areas(ii) = lst(ii,:) = [];


The VM gives a size mismatch error, and only one of the arrays has been reduced. The other is still untouched, and the error message indicates that it interpreted "= []" as an array assignment instead of a deletion.


octave:1> echo on
octave:2> testvm
+ ## test VM
+
+ lst = rand (285, 16);
+ areas = rand (285, 1);
+ ii = true (285, 1);
+ ii([18 33 34 38 45 57 74 91 130 154 176 213 246 279]) = 0;
+ areas(ii) = lst(ii,:) = [];
error: =: nonconformant arguments (op1 is 271x1, op2 is 0x0)
error: called from
    testvm at line 5 column 4
octave:3>
octave:3> whos
Variables visible from the current scope:

variables in scope: top scope

  Attr   Name        Size                     Bytes  Class
  ====   ====        ====                     =====  =====
         areas     285x1                       2280  double
         ii        285x1                        285  logical
         lst        14x16                      1792  double

Total is 794 elements using 4357 bytes


Without the VM, the code evaluates as intended:


octave:4> clear all
octave:5> __enable_vm_eval__ (0)
octave:6>
octave:6> testvm
+ ## test VM
+
+ lst = rand (285, 16);
+ areas = rand (285, 1);
+ ii = true (285, 1);
+ ii([18 33 34 38 45 57 74 91 130 154 176 213 246 279]) = 0;
+ areas(ii) = lst(ii,:) = [];
+
+
octave:7> whos
Variables visible from the current scope:

variables in scope: top scope

  Attr   Name        Size                     Bytes  Class
  ====   ====        ====                     =====  =====
         areas      14x1                        112  double
         ii        285x1                        285  logical
         lst        14x16                      1792  double

Total is 523 elements using 2189 bytes


Arun Giridhar <arungiridhar>
Group Member

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #55160:  octave_32322.patch added by petter (9KiB - text/plain)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by jwe (Updated the item)
  • -email is unavailable- added by petter (Updated the item)
  • -email is unavailable- added by arungiridhar (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-10-09 jwe CategoryJIT Acceleration Interpreter
    2023-10-01 arungiridhar StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2023-09-23 arungiridhar StatusNone Ready For Test
    2023-09-23 petter Attached File- Added octave_32322.patch, #55160

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code