Weird NPE when ObjectSpace._id2ref called for GC'ed object in conditional 
statement
-----------------------------------------------------------------------------------

                 Key: JRUBY-1125
                 URL: http://jira.codehaus.org/browse/JRUBY-1125
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.0.0
            Reporter: Bill Dortch


This is a really strange one.  The source of Cheri's (CJX) NPE's, BTW, but easy 
enough to work around.
{code}
>> # make an object
?> x = 'xxx'
=> "xxx"
>> # remember its id
?> x.object_id
=> 6
>> ObjectSpace._id2ref 6
=> "xxx"
>> # now kill it good and dead
?> x = nil
=> nil
>> GC.start
=> nil
>> # see if ObjectSpace finds it
?> ObjectSpace._id2ref 6
=> nil
>> # now try it in a conditional
?> if ObjectSpace._id2ref 6
>> end
NativeException: java.lang.NullPointerException: null
        from EvaluationState.java:272:in 
`org.jruby.evaluator.EvaluationState.evalInternal'
        from EvaluationState.java:1609:in 
`org.jruby.evaluator.EvaluationState.rootNode'
        from EvaluationState.java:356:in 
`org.jruby.evaluator.EvaluationState.evalInternal'
        from EvaluationState.java:164:in 
`org.jruby.evaluator.EvaluationState.eval'
        from RubyObject.java:888:in `org.jruby.RubyObject.evalWithBinding'
        from RubyKernel.java:755:in `org.jruby.RubyKernel.eval'
        from null:-1:in `org.jruby.RubyKernelInvokerSevalxx1.call'
        from InvocationCallback.java:49:in 
`org.jruby.runtime.callback.InvocationCallback.execute'
        from FullFunctionCallbackMethod.java:78:in 
`org.jruby.internal.runtime.methods.FullFunctionC
allbackMethod.internalCall'
        from DynamicMethod.java:79:in 
`org.jruby.internal.runtime.methods.DynamicMethod.call'
        from EvaluationState.java:1023:in 
`org.jruby.evaluator.EvaluationState.fCallNode'
        from EvaluationState.java:253:in 
`org.jruby.evaluator.EvaluationState.evalInternal'
        from EvaluationState.java:164:in 
`org.jruby.evaluator.EvaluationState.eval'
        from DefaultMethod.java:136:in 
`org.jruby.internal.runtime.methods.DefaultMethod.internalCal
l'
        from DynamicMethod.java:79:in 
`org.jruby.internal.runtime.methods.DynamicMethod.call'
        from EvaluationState.java:568:in 
`org.jruby.evaluator.EvaluationState.callNode'
... 95 levels...
        from Ruby.java:319:in `org.jruby.Ruby.compileOrFallbackAndRun'
        from Main.java:228:in `org.jruby.Main.runInterpreter'
        from Main.java:173:in `org.jruby.Main.runInterpreter'
        from Main.java:120:in `org.jruby.Main.run'
        from Main.java:95:in `org.jruby.Main.main'
        from C:/jruby/jruby-1.0.0/lib/ruby/1.8/irb.rb:150:in `eval_input'
        from C:/jruby/jruby-1.0.0/lib/ruby/1.8/irb.rb:70:in `signal_status'
        from C:/jruby/jruby-1.0.0/lib/ruby/1.8/irb.rb:189:in `eval_input'
        from C:/jruby/jruby-1.0.0/lib/ruby/1.8/irb.rb:70:in 
`each_top_level_statement'
        from C:/jruby/jruby-1.0.0/lib/ruby/1.8/irb.rb:190:in `loop'
        from C:/jruby/jruby-1.0.0/lib/ruby/1.8/irb.rb:190:in `catch'
        from C:/jruby/jruby-1.0.0/lib/ruby/1.8/irb.rb:190:in `eval_input'
        from C:/jruby/jruby-1.0.0/lib/ruby/1.8/irb.rb:70:in `start'
        from :-1:in `catch'
        from C:/jruby/jruby-1.0.0/lib/ruby/1.8/irb.rb:71:in `start'
        from :-1>>
{code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to