Skip to content

Invalid opcode EXT2 when running a large script #188

Description

@YoruYomix

Hi, thanks for ChibiRuby — been using it in a Unity project and it's been working well until now.

Ran into a crash with a bigger script:

NotSupportedException: Invalid opcode EXT2
  ChibiRuby.MRubyState.<Execute>g__ThrowInvalidOpCode|344_11 (ChibiRuby.OpCode opcode)
  ChibiRuby.MRubyState.Execute (...)
  ChibiRuby.RFiber.Resume (...)

I dug into it a bit and it looks like EXT1/EXT2/EXT3 aren't actually handled in the VM. In OpCode.cs they're in the enum but marked not implemented, so Execute just hits ThrowInvalidOpCode.

My script has a lot of string literals in one method, so I'm guessing the pool index goes over 255 and the compiler emits the EXT2 prefix to widen the operand. The compiler side generates it fine but the VM can't run it.

For now I worked around it by splitting the oversized method into smaller ones, so no single irep's literal pool exceeds 255. It works, but it'd be nice to have EXT1/2/3 supported so this isn't a problem.

Version 1.5.0, netstandard2.1, Unity on Windows.

Let me know if you want a repro, I can put one together.

Also, unrelated to the issue itself —

I really enjoyed your presentation at RubyKaigi 2026.
I genuinely think this is a great project.
I'm making heavy use of ChibiRuby and VitalRouter in the game I'm building.

Without any separate scenario files like CSV or JSON, I'm handling everything right in the Ruby scripts: game dialogue, graphics direction, stat gains, save/load, all of it.
By combining ChibiRuby with VitalRouter's interceptor pipeline and command ordering, I've been able to implement almost everything I wanted. For example, when ChibiRuby's script publishes a command through VitalRouter, an interceptor swaps the text based on the language setting — that kind of thing.
I've been recommending it to people around me on Twitter.

Thank you for building and maintaining such a great project.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions