bugGNU Octave - Bugs: bug #64817, VM seems to get out of sync in...


bug #64817: VM seems to get out of sync in certain situations and throws error / produces core dump

Submitter:  None
Submitted:  Thu 26 Oct 2023 03:43:35 AM UTC
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Ready For Test Assigned to:  None
Originator Name:  Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Sat 28 Oct 2023 02:25:16 PM UTC, comment #2: 

I've made a patch that addresses the issue.

Don't mix up field and id slots when creating bytecode script frames (bug #64817)

Instead of looking up variables by name lineary in the slot name data, use
a map.

* stack-frame.cc: Use map for id lookup
* pt-bytecode-walk.cc: Populate map
* pt-bytecode.h: Change set to map
* test/compile/bytecode_struct.m: Update tests
* test/compile/module.mk: Add new test script
* test/compile/script_defines_qweqwe.m: New test script

Builds on:

(file #55287)

Petter <petter>
Thu 26 Oct 2023 10:42:21 PM UTC, comment #1: 

Thanks for the test. I am able to replicate the issue.

Petter <petter>
Thu 26 Oct 2023 03:43:35 AM UTC, original submission:  

The VM either
- throws an error „VM internal error: Invalid internal offset. Smaller than original size and not in table“ when calling a script OR
- produces a core dump when the same script commands are just executed on the command line OR
- produces a core dump when the logic the enable/disable the VM is removed from a script and the VM just enabled on the command line.

Overall adding or removing a variable or exchanging a variable to a struct variable or slightly changing the logic seems to have an impact on the error, so I guess that the VM gets out of sync. Also important seems to have an unknown function / unknown function parameter as struct in the code (but this code will never be executed), but the error/core dump yes/no logic related to any code changes escapes me...

The HG-id is ffc410f26506, so all VM patches before today are in.

When calling test1.m, the VM throws an error:
"VM internal error: Invalid internal offset. Smaller than original size and not in table
VM error 7566: Exception in Snippet_test3 escaped the VM
error: VM error 7567: Exception in Snippet_test3 escaped the VM
error: called from
    test2 at line 3 column 3
    test1 at line 4 column 6"

When the same commands are executed on the command line, a core dump is produced.

When the VM enable/disable logic lines are removed from Snippet_test3.m, the VM enabled on the command line and test1.m is executed, a core dump is produced.

Without the VM active (e.g. setting VM_Compile = false or simply removing the lines in the script), there is no problem.


source Snippet_test3.m
 New = test2(0);
until New;


function retval = test2 (t1)

  source Snippet_test3.m;
  Fs = readdir(files.model_path);
    if false
      P = I_Do_No_Exist(Var_Does_Not_Exist_As_Well.Take);
  until true

  retval = !t1;


files = struct();
files.model_path = pwd ();
Fs = readdir(files.model_path);
Take = false(size(Fs));

# if all the lines below are removed and the VM is just enabled on the command line,
# then a core dump is produced without the VM throwing an error.
VM_Compile = true;
if VM_Compile
  __vm_enable__ (1);
  __vm_enable__ (0);



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

Attach Files:

Attached Files
file #55287:  octave_32632.patch added by petter (12KiB - 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 arungiridhar (Updated the item)
  • -email is unavailable- added by petter (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 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-10-28 arungiridhar StatusNone Ready For Test
    2023-10-28 petter Attached File- Added octave_32632.patch, #55287

    Back to the top

    Powered by Savane 3.13-3cd0.
    Corresponding source code