-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Core method call missing in exception backtrace on JRuby 9.2.0.0 #5200
Comments
I suspect this is due to a numeric optimization that bypasses the known Ruby core method and goes straight to other logic. We would just want to register those other method names so that they are transformed into a core method backtrace line. If you specify -Xbacktrace.style=full, you'll see all the intermediate and Ruby lines together in a single trace. |
This may originally have been because we had some special-case methods for faster math operations. Now the root cause is that all these methods are defined on RubyInteger, which is how they're entered into the backtrace scrubber. But when dispatched against RubyFixnum or RubyBignum, they don't ever pass through RubyInteger, so that trace line is lost. Brainstorming a fix... We could make the Ruby-bound methods redispatch to a different name, so they would not be overridable (and could be marked as final to ensure they don't get overridden. However all dispatches from within RubyInteger would be bimorphic against RubyFixnum and RubyBignum, rather than the original call site seeing only one or the other. We could modify the JRubyMethod annotation, or the processing of it, to list or find subclass overrides, and also add those classes to the mapping table for method names. If this were done manually, it would be error-prone, and done automatically would require digging up all child classes during populator generation. It's doable though. We could introduce another annotation used to generate a populator for the name mapping, It would be another build step and another generated piece of code to run on boot, but it could accurately reflect all class/method combinations we want to map to a different Ruby name, including specialized locations such as our "helpers" classes or utility methods in the interpreter. This seems like the best idea, but has the most work involved. @enebo Gimme your $0.02! |
There's a bit more complication here with the Integer integration. Our backtraces are based on matching an exact class plus method name in the Java trace, which works fine for classes that implement their own Ruby-facing methods. RubyInteger, however, has mostly abstract implementations of these methods, implemented in the two subclasses RubyBignum and RubyFixnum. That prevents the stack trace from reflecting the RubyInteger class and as a result none of these methods will show up in a Ruby trace. This is a specific example of the general problem that methods not directly bound via |
Our Ruby backtrace-generation logic depends on a mapping of class and method names to their equivalent Ruby name, but this fails when the JRubyMethod annotation is on an abstract method implemented by one or more subclasses. The subclasses are not registered in the mapping and when their overridden methods appear in the Java stack trace they will not be replaced with their Ruby equivalent. This patch adds support for JRubyMethod.implementers, a list of additional classes to include in the mapping table. This is a naive change currently, in that it assumes all methods on class A should also be mapped for class B < A regardless of whether they are actually overridden or not. This is a first pass at fixing the missing trace lines reported in issue jruby#5200.
I have pushed a PR that should fix this, at least for Integer, Method/UnboundMethod, and the specialized Array subtypes for one and two-element lists. We will land that for 9.3. |
I noticed some very minor issue with the exception backtraces in JRuby 9.2.0.0: there is a core method call missing in the output of this script:
See Actual Behavior below for the program output when running with JRuby 9.2.0.0.
Normal Ruby exceptions (via
raise
) show up correctly, and so do pure Java exceptions.Environment
jruby -v
:No
JRUBY_OPTS
setOS:
Expected Behavior
Same as in JRuby 9.1.17.0 -- there should be a call to the
/
method somewhere in the backtrace:For comparison, here's the same script run with MRI 2.5.0:
Actual Behavior
The text was updated successfully, but these errors were encountered: