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

NullPointerException in IRClosure #1741

Closed
donv opened this issue Jun 11, 2014 · 8 comments
Closed

NullPointerException in IRClosure #1741

donv opened this issue Jun 11, 2014 · 8 comments

Comments

@donv
Copy link
Member

donv commented Jun 11, 2014

Got the exception below when using master in Ruboto today. I can probably find which source file was loaded if it would be helpful.

java.lang.NullPointerException
   at org.jruby.ir.IRClosure.<init>(IRClosure.java:64)
   at org.jruby.ir.IREvalScript.<init>(IREvalScript.java:32)
   at org.jruby.ir.IRBuilder.buildEvalRoot(IRBuilder.java:3220)
   at org.jruby.ir.interpreter.Interpreter.interpretCommonEval(Interpreter.java:135)
   at org.jruby.ir.interpreter.Interpreter.interpretSimpleEval(Interpreter.java:163)
   at org.jruby.ir.interpreter.Interpreter.evalSimple(Interpreter.java:733)
   at org.jruby.RubyBasicObject.evalUnder(RubyBasicObject.java:1798)
   at org.jruby.RubyBasicObject.specificEval(RubyBasicObject.java:1748)
   at org.jruby.RubyBasicObject.instance_eval19(RubyBasicObject.java:1581)
   at org.jruby.RubyBasicObject$INVOKER$i$instance_eval19.call(RubyBasicObject$INVOKER$i$instance_eval19.gen)
   at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrOneOrTwoOrThreeBlock.call(JavaMethod.java:519)
   at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:180)
   at org.jruby.RubyClass.finvoke(RubyClass.java:662)
   at org.jruby.runtime.Helpers.invoke(Helpers.java:542)
   at org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.callEachType(EmbedRubyObjectAdapterImpl.java:353)
   at org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.call(EmbedRubyObjectAdapterImpl.java:306)
   at org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.runRubyMethod(EmbedRubyObjectAdapterImpl.java:278)
   at org.jruby.embed.ScriptingContainer.runRubyMethod(ScriptingContainer.java:1528)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at org.ruboto.JRubyAdapter.runRubyMethod(JRubyAdapter.java:51)
   at org.ruboto.test.InstrumentationTestRunner.loadScript(InstrumentationTestRunner.java:171)
   at org.ruboto.test.InstrumentationTestRunner.getAllTests(InstrumentationTestRunner.java:100)
   at android.test.InstrumentationTestRunner.getTestSuite(InstrumentationTestRunner.java:580)
   at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:360)
   at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4335)
   at android.app.ActivityThread.access$1500(ActivityThread.java:135)
   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
   at android.os.Handler.dispatchMessage(Handler.java:102)
   at android.os.Looper.loop(Looper.java:136)
   at android.app.ActivityThread.main(ActivityThread.java:5017)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:515)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
   at dalvik.system.NativeStart.main(Native Method)
@enebo
Copy link
Member

enebo commented Jun 11, 2014

@donv Yeah that would be excellent.

@donv
Copy link
Member Author

donv commented Aug 8, 2014

Finally got down to look at this again. The file in question is ruboto_test_app_activity_test.rb:

activity Java::org.ruboto.test_app.RubotoTestAppActivity

setup do |activity|
  start = Time.now
  loop do
    @text_view = activity.findViewById(42)
    break if @text_view || (Time.now - start > 60)
    sleep 1
  end
  assert @text_view
end

test('initial setup') do |activity|
  assert_equal 'What hath Matz wrought?', @text_view.text
end

test('button changes text', :ui => false) do |activity|
  button = activity.findViewById(43)
  clicked_at = nil
  activity.run_on_ui_thread do
    button.performClick
    clicked_at = Time.now
  end

  sleep 0.1 until clicked_at && (@text_view.text == 'Broadcast received!' || (Time.now - clicked_at) > 10)

  assert_equal 'Broadcast received!', @text_view.text
end

The stack trace now is:

W/System.err( 3277): java.lang.NullPointerException: Attempt to invoke virtual method 'int org.jruby.ir.IRScope.getNextClosureId()' on a null object ref
erence
W/System.err( 3277):    at org.jruby.ir.IRClosure.<init>(IRClosure.java:49)
W/System.err( 3277):    at org.jruby.ir.IREvalScript.<init>(IREvalScript.java:33)
W/System.err( 3277):    at org.jruby.ir.IRBuilder.buildEvalRoot(IRBuilder.java:3169)
W/System.err( 3277):    at org.jruby.ir.interpreter.Interpreter.interpretCommonEval(Interpreter.java:79)
W/System.err( 3277):    at org.jruby.ir.interpreter.Interpreter.interpretSimpleEval(Interpreter.java:110)
W/System.err( 3277):    at org.jruby.ir.interpreter.Interpreter.evalSimple(Interpreter.java:701)
W/System.err( 3277):    at org.jruby.RubyBasicObject.evalUnder(RubyBasicObject.java:1845)
W/System.err( 3277):    at org.jruby.RubyBasicObject.specificEval(RubyBasicObject.java:1795)
W/System.err( 3277):    at org.jruby.RubyBasicObject.instance_eval19(RubyBasicObject.java:1623)
W/System.err( 3277):    at org.jruby.RubyBasicObject$INVOKER$i$instance_eval19.call(RubyBasicObject$INVOKER$i$instance_eval19.gen)
W/System.err( 3277):    at org.jruby.internal.runtime.methods.JavaMethod$JavaMethodZeroOrOneOrTwoOrThreeBlock.call(JavaMethod.java:535)
W/System.err( 3277):    at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:180)
W/System.err( 3277):    at org.jruby.RubyClass.finvoke(RubyClass.java:663)
W/System.err( 3277):    at org.jruby.runtime.Helpers.invoke(Helpers.java:583)
W/System.err( 3277):    at org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.callEachType(EmbedRubyObjectAdapterImpl.java:353)
W/System.err( 3277):    at org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.call(EmbedRubyObjectAdapterImpl.java:306)
W/System.err( 3277):    at org.jruby.embed.internal.EmbedRubyObjectAdapterImpl.runRubyMethod(EmbedRubyObjectAdapterImpl.java:278)
W/System.err( 3277):    at org.jruby.embed.ScriptingContainer.runRubyMethod(ScriptingContainer.java:1554)
W/System.err( 3277):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 3277):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err( 3277):    at org.ruboto.JRubyAdapter.runRubyMethod(JRubyAdapter.java:51)
W/System.err( 3277):    at org.ruboto.test.InstrumentationTestRunner.loadScript(InstrumentationTestRunner.java:171)
W/System.err( 3277):    at org.ruboto.test.InstrumentationTestRunner.getAllTests(InstrumentationTestRunner.java:100)
W/System.err( 3277):    at android.test.InstrumentationTestRunner.getTestSuite(InstrumentationTestRunner.java:581)
W/System.err( 3277):    at android.test.InstrumentationTestRunner.onCreate(InstrumentationTestRunner.java:361)
W/System.err( 3277):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4388)
W/System.err( 3277):    at android.app.ActivityThread.access$1500(ActivityThread.java:143)
W/System.err( 3277):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
W/System.err( 3277):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err( 3277):    at android.os.Looper.loop(Looper.java:135)
W/System.err( 3277):    at android.app.ActivityThread.main(ActivityThread.java:5070)
W/System.err( 3277):    at java.lang.reflect.Method.invoke(Native Method)
W/System.err( 3277):    at java.lang.reflect.Method.invoke(Method.java:372)
W/System.err( 3277):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:836)
W/System.err( 3277):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:631)

@enebo any ideas?

@enebo
Copy link
Member

enebo commented Aug 8, 2014

@donv I only looked at this for a few minutes but I suspect however we setup eval via embedding might not be passing in an enclosing IRScope (which is where the NPE is from). Once I stabilze my current parser work I will try and set up a test for this. I believe however ruboto calls through scriptingcontainer must be exposing a bug since we cut over to IR.

@donv
Copy link
Member Author

donv commented Sep 21, 2014

Hi @enebo !

I am still getting this. Have you stabilised the parser? Any chance you could look at this again? It is the only known issue preventing using master with Ruboto.

@enebo enebo added this to the JRuby 9000 milestone Sep 23, 2014
@enebo
Copy link
Member

enebo commented Sep 23, 2014

Can you link ruboto ScriptingContainer code to this issue? If I can see how you are invoking scriptingcontainer hopefully I can reproduce this on Java and make a testcase. The line makes it clear we are missing the parent scope. So my educated guess is probably right that how we hook up scriptingcontainer is passing in a null parent scope.

@donv
Copy link
Member Author

donv commented Oct 15, 2014

Hi @enebo !

Sorry for the delay. I finally got Ruboto 1.2.0 out, so I have a bit more time :) My backlog is huge!

Here is a link to the code to set up the ScriptingContainer. Please ask if I can clarify it.

https://github.com/ruboto/ruboto/blob/master/assets/src/org/ruboto/JRubyAdapter.java#L127

@enebo
Copy link
Member

enebo commented Oct 16, 2014

@donv could you remove the passes and try again. I am curious if there is
something wrong with just that combination of passes. We do not permute
all pass combos yet.

On Wed, Oct 15, 2014 at 5:01 PM, Uwe Kubosch notifications@github.com
wrote:

Hi @enebo https://github.com/enebo !

Sorry for the delay. I finally got Ruboto 1.2.0 out, so I have a bit more
time :) My backlog is huge!

Here is a link to the code to set up the ScriptingContainer. Please ask if
I can clarify it.

https://github.com/ruboto/ruboto/blob/master/assets/src/org/ruboto/JRubyAdapter.java#L127


Reply to this email directly or view it on GitHub
#1741 (comment).

blog: http://blog.enebo.com twitter: tom_enebo
mail: tom.enebo@gmail.com

@kares
Copy link
Member

kares commented Mar 1, 2018

let's call this one resolved by now 👴

@kares kares closed this as completed Mar 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants