bugGNU Octave - Bugs: bug #65304, bytecode compiler fails with VM...


bug #65304: bytecode compiler fails with VM error 5274

Submitter:  A.R. Burgers <arb>
Submitted:  Tue 13 Feb 2024 03:26:11 PM UTC
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Patch Submitted Assigned to:  None
Originator Name:  Open/Closed:  * Open
Release:  * bytecode-evaluator Operating System:  * GNU/Linux
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup

Fri 05 Apr 2024 06:36:50 PM UTC, comment #4: 

I noted those, too.

FWIW, I regularly make Linux builds and Windows (cross-)builds and AFAIK I have all of Petter's patches included + one by "Fernando" (bug #64783). I see no bytecode-interpreter related (or suspected) failures running the test suite on Linux and Windows.

That said, ATM I don't use Octave very much at work (that might change in the next weeks) so I guess due to that I don't hit problems other than cosmetic ones.

Philip Nienhuis <philipnienhuis>
Group Member
Fri 05 Apr 2024 02:45:31 AM UTC, comment #3: 

octave_33191.patch needs to be refreshed: "Hunk #12 FAILED at 6433.". This refresh is required due to the commit from Tue Mar 26: Change "assert" to "panic_unless".

-    assert (N_RETURNS () == -128);
+    assert (N_RETURNS () == -32768);

should be refreshed to

-    panic_unless (N_RETURNS () == -128);
+    panic_unless (N_RETURNS () == -32768);

The state of the bytecode compiler branch degrades creating additional effort and reducing usability for the broader community:

A number of (rather serious) bytecode compiler bugs are still in the pipeline with a patch provided since quite a while by Petter (some since more than 6 weeks), but not yet reviewed and migrated.
See also https://octave.discourse.group/t/wip-stack-vm-for-octave/2884/186.

Hendrik K <koerhen>
Wed 14 Feb 2024 10:59:27 PM UTC, comment #2: 

Here are two patches that should solve the issue.

The first patch allows for more than 255 arguments, up to 2^16-1 in an index operation.

The other patch allows for more than 255, up to 2^15-1, named arguments or return symbols when compiling a function.

Allow more than 255 arguments to index operations in bytecode (bug #65304)

Change some opcodes to use 2 bytes for number of args and use them when
the number of args is bigger than 255. INDEX_STRUCT_SUBCALL, INDEX_STRUCT_CALL,

* pt-bytecode-vm.cc: Use two bytes for number of args for the opcodes
* pt-bytecode-walk.cc: Use the opcodes when many args

Support more than 255 named arguments and returns in the bytecode interpreter (bug #65304)

Use two bytes to store the amount of argument symbols and return symbols, to allow
for 2^15-1 symbols. Replace magic anon. fn. marker -128 with -32768.

* pt-bytecode-vm-internal.h: Change size to two bytes
* pt-bytecode-vm.cc: Change size to two bytes
* pt-bytecode-walk.cc: Emit two bytes
                       Error check new limits
* bytecode_subfuncs.m: Update tests

(file #55703, file #55704)

Petter <petter>
Tue 13 Feb 2024 10:49:53 PM UTC, comment #1: 

Thanks for the report. You hit the 255 argument limit for index operations. I guess that it should be quite common to want to do that for those kind of constellations, so the limit is probably too low.

I've made a patch that would support up to 2^16-1 arguments. I'll attach a wip version that you could try, but I think there might be other opcodes that need "many args" support, so I'll clean it up and see if I can find more places that could be an issue. At least chained index operations e.g. "struct ( .. many args .. ).qwe;" would need it too.

(file #55692)

Petter <petter>
Tue 13 Feb 2024 03:26:11 PM UTC, original submission:  

The attached function fails to compile with VM error 5274.

sample code:

version -hgid

gives this output and error:

octave:8> version -hgid
ans = 19973af3ac42
octave:9> VM_fail;
warning: auto-compilation of VM_fail failed with message VM error 5274: internal VM compiler consistency check failed, code_check_s_ < 256 && code_check_s_ >= -128

A.R. Burgers <arb>


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

Attach Files:

Attached Files
file #55703:  octave_33190.patch added by petter (7KiB - text/plain)
file #55704:  octave_33191.patch added by petter (17KiB - text/plain)
file #55692:  33183.patch added by petter (4KiB - text/plain)
file #55690:  VM_fail.m added by arb (35KiB - 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 koerhen (Posted a comment)
  • -email is unavailable- added by petter (Updated the item)
  • -email is unavailable- added by arb (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
    2024-02-21 philipnienhuis StatusNone Patch Submitted
    2024-02-14 petter Attached File- Added octave_33190.patch, #55703
        Attached File- Added octave_33191.patch, #55704
    2024-02-13 petter Attached File- Added 33183.patch, #55692
    2024-02-13 arb Attached File- Added VM_fail.m, #55690

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code