Skip to content

Hosted code (ScriptEngine.Execute): backtrace frames missing, stale file/line, line 0, CLR frames below <main> #163

Closed

Description

@Largo

Found while fixing #158 (backtrace labels for hosted code). The labels now match CRuby 4.0, but four other problems remain on the hosting path (ScriptEngine.Execute, ScriptSource.Execute, IronRuby.Tests' CompilerTest). ir is not affected.

Snippet (same as #158):

def many
  raise ArgumentError, 'x'
end

class Foo
  def bar = many
  def self.baz = new.bar
end

begin
  [1].each { Foo.baz }
rescue => e
  puts e.backtrace
end
  1. Missing frame: when the snippet runs through CompilerTest first in a fresh runtime, the raising Object#many frame is missing from e.backtrace entirely.
  2. Stale file and line: after one Engine.Execute, later runs of the same code report the many frame as (eval):2 (a stale file and the def line), even when the source is hosted.rb.
  3. Line 0: Engine.Execute reports the Array#each and <main> frames at line 0.
  4. CLR host frames below <main>: frames such as :0:in 'CompilerTest' and RunTestCase appear below <main>. CRuby shows nothing below <main>.

Also, a known difference left by #158: an explicit def self.x in hosted top-level code is labelled Object#x, where CRuby prints x. Hosted top-level defs land on main's singleton class, so the two cases can't be told apart.

Backtrace_HostedLabels1 (added for #158) checks only the labels, so it does not depend on any of these.

🤖 Generated with Claude Code

Activity

  1. added 2 commits that reference this issue on Nov 9, 2026
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions