Deadlock With ReentrantLock and Java Integration
------------------------------------------------

                 Key: JRUBY-2270
                 URL: http://jira.codehaus.org/browse/JRUBY-2270
             Project: JRuby
          Issue Type: Bug
          Components: Java Integration
    Affects Versions: JRuby 1.1RC2
         Environment: Java 6
            Reporter: Peter K Chan


When I run my multithreaded app using JRuby 1.1 RC2, deadlock results.

I am not sure about what happens, but my app uses ReentrantLock. My guess is 
that there is some synchronization done around JavaClass$InstanceMethodInvoker, 
which deadlocks when one thread holds the JavaClass$InstanceMethodInvoker and 
tries to acquire lock (using Java Integration) on a target ReentrantLock, while 
that target lock is being held by another thread that is looking to lock on to 
JavaClass$InstanceMethodInvoker (probably to call other Java methods before 
unlocking the target lock).

The following output from JConsole's deadlock tab provides a snapshot of the 
deadlock in action:

=== Thread "main" ===
Name: main
State: WAITING on [EMAIL PROTECTED] owned by: Tasker
Total blocked: 52,224  Total waited: 231

Stack trace: 
sun.misc.Unsafe.park(Native Method)
java.util.concurrent.locks.LockSupport.park(LockSupport.java:158)
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:712)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:743)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1079)
java.util.concurrent.locks.ReentrantLock$NonfairSync.lock(ReentrantLock.java:186)
java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:262)
sun.reflect.GeneratedMethodAccessor33.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:597)
org.jruby.javasupport.JavaMethod.invokeWithExceptionHandling(JavaMethod.java:208)
org.jruby.javasupport.JavaMethod.invoke(JavaMethod.java:184)
org.jruby.javasupport.JavaClass$InstanceMethodInvoker.execute(JavaClass.java:406)
   --- locked [EMAIL PROTECTED]
org.jruby.internal.runtime.methods.SimpleCallbackMethod.call(SimpleCallbackMethod.java:67)
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:66)
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:298)
org.jruby.evaluator.ASTInterpreter.callNode(ASTInterpreter.java:657)
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:308)
org.jruby.evaluator.ASTInterpreter.blockNode(ASTInterpreter.java:631)
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:302)
org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:168)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:176)
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:66)
org.jruby.runtime.CallSite$InlineCachingCallSite.cacheAndCall(CallSite.java:166)
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:301)
(snip)

=== Thread "Tasker" ===
Name: Tasker
State: BLOCKED on [EMAIL PROTECTED] owned by: main
Total blocked: 1  Total waited: 2

Stack trace: 
org.jruby.javasupport.JavaClass$InstanceMethodInvoker.execute(JavaClass.java:384)
org.jruby.internal.runtime.methods.SimpleCallbackMethod.call(SimpleCallbackMethod.java:67)
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:66)
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:298)
org.jruby.evaluator.ASTInterpreter.callNode(ASTInterpreter.java:657)
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:308)
org.jruby.evaluator.ASTInterpreter.blockNode(ASTInterpreter.java:631)
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:302)
org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:168)
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:176)
org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:66)
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:298)
org.jruby.evaluator.ASTInterpreter.fCallNode(ASTInterpreter.java:1100)
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:354)
org.jruby.evaluator.ASTInterpreter.localAsgnNode(ASTInterpreter.java:1256)
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:387)
org.jruby.evaluator.ASTInterpreter.blockNode(ASTInterpreter.java:631)
org.jruby.evaluator.ASTInterpreter.evalInternal(ASTInterpreter.java:302)
org.jruby.evaluator.ASTInterpreter.eval(ASTInterpreter.java:168)
(snip)

-- 
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