Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread::Backtrace::Location#label inside eval does not return enclosing method name #5164

ivoanjo opened this issue May 10, 2018 · 0 comments


Copy link

@ivoanjo ivoanjo commented May 10, 2018

Hello again!

I'm using Thread#backtrace_locations and noticed several differences between MRI and JRuby.

I'll report them separately because they may have different fixes, but feel free to mark any as duplicate if it makes sense to do so.


  • JRuby: jruby (2.3.3) 2018-04-20 d8b1ff9 Java HotSpot(TM) 64-Bit Server VM 25.171-b11 on 1.8.0_171-b11 +jit [linux-x86_64]
  • Kernel: Linux u186024434db159d25c92 4.13.0-39-generic #44~16.04.1-Ubuntu SMP Thu Apr 5 16:43:10 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
  • Distro: Ubuntu 16.04.4 LTS

Expected Behavior

On MRI, when getting the Location for an eval()'d stack, the #label is set as the enclosing method.



def test
      location = Thread.current.backtrace_locations[1]
      puts "#base_label '#{location.base_label}', #label '#{location.label}', #to_s '#{location}'"


Output on MRI:

ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
#label 'test', #to_s '(eval):1:in `test''

Actual Behavior

JRuby just returns <eval> for both #label (and #base_label):

jruby (2.3.3) 2018-04-20 d8b1ff9 Java HotSpot(TM) 64-Bit Server VM 25.171-b11 on 1.8.0_171-b11 +jit [linux-x86_64]
#label '<eval>', #to_s '(eval):1:in `<eval>''

If it would be helpful I can also submit a testcase to RubySpec.

@headius headius added this to the JRuby milestone May 14, 2018
enebo added a commit that referenced this issue Jun 14, 2018
…eturn enclosing method name.

This one is pretty weird.  I just switched to from <eval> and the
test ran fine.  I noticed that top-level evals were not printing out <main>, so
I tweaked a few things.  JIT will apparently set frame method name to '' vs
null so I am not sure what is up there.

# Conflicts:
#	core/src/main/java/org/jruby/ir/interpreter/
@enebo enebo closed this in da1b6c9 Jun 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants