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

NPE in IRDumper.print_ir on JRuby 9.3 #8158

Open
kalenp opened this issue Mar 20, 2024 · 1 comment
Open

NPE in IRDumper.print_ir on JRuby 9.3 #8158

kalenp opened this issue Mar 20, 2024 · 1 comment

Comments

@kalenp
Copy link

kalenp commented Mar 20, 2024

I'm getting an NPE when trying to dump the IR. Per suggestion from @headius, I added this code snippet immediately after a class definition (sample MyClass):

class MyClass
  def get
    ...
  end
end

def dump_ir
  m = MyClass.instance_method(:get)
  jm = JRuby.ref(m)
  scope = jm.get_method.get_ir_scope
  printed_ir = org.jruby.ir.persistence.IRDumper.print_ir(scope, true)
  bytes = printed_ir.to_byte_array
  puts String.from_java_bytes(bytes)
end

dump_ir()

This fails at the IRDumper.print_ir line with the error:

LoadError: load error: <file> -- java.lang.NullPointerException: null
require at org/jruby/RubyKernel.java:1017
<main> at <file>.rb
...

I also tried it with another method on a module with the same result, eg

module MyModule
  module_function def get
    ...
  end
end

m = MyModule.method(:get)

Environment Information

  • jruby 9.3.13.0 (2.6.8) 2023-11-02 09b6f22 OpenJDK 64-Bit Server VM 11.0.15+0-adhoc..source on 11.0.15+0-adhoc..source +jit [x86_64-linux]
  • Linux localhost 6.5.13-1rodete2-amd64 break script engine #1 SMP PREEMPT_DYNAMIC Debian 6.5.13-1rodete2 (2024-01-11) x86_64 GNU/Linux
@enebo
Copy link
Member

enebo commented Mar 21, 2024

If I try:

require 'jruby'

class MyClass
  def get
    1 + 1
  end
end

def dump_ir
  m = MyClass.instance_method(:get)
  jm = JRuby.ref(m)
  scope = jm.get_method.get_ir_scope
  printed_ir = org.jruby.ir.persistence.IRDumper.print_ir(scope, true)
  bytes = printed_ir.to_byte_array
  puts String.from_java_bytes(bytes)
end

dump_ir

I get:

system ~/work/jruby-9.5 9.5-dev * 5543% ~/releases/9.3.14.0/jruby-9.3.14.0/bin/jruby -v ../snippets/ir_dump.rb
jruby 9.3.14.0 (2.6.8) 2024-02-20 0db23ddd14 OpenJDK 64-Bit Server VM 20.0.1+9-29 on 20.0.1+9-29 +jit [x86_64-linux]
begin INSTANCE_METHOD<get>
flags: [FLAGS_COMPUTED]
signature(pre=0,opt=0,post=0,rest=NONE,kwargs=0,kwreq=0,kwrest=-1)

block #1 (out: 3,2): LBL_0:-1

block #2 (out: 3): LBL_1:-1
  0:         check_arity(required: 0, opt: 0, rest: false, receivesKeywords: false, restKey: -1)
  1:         line_num(lineNumber: 4, coverage: false, oneshot: false)
  2: %v_2 := call_1f(fix<1>, fix<1>, fixNum: 1, callType: NORMAL, name: +, potentiallyRefined: false)
  3:         return(%v_2)

block #3: LBL_2:-1

I am guessing something specific where the '...' is in your report is not printing and causing a NPE. You can also try adding -Xlog.backtraces or -Xlog.exceptions. Possibly even -Xbacktrace.style=raw will give your more info where the NPE is happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants