Deadlock scenarios
flavia.rainone Jan 2, 2008 2:02 PMDuring rebuildingchain test execution, we are seeing a couple of deadlock scenarios... those are related to classload time weaving and dynamic AOP operations.
I have created a bug issue:
http://jira.jboss.com/jira/browse/JBAOP-499
With two subtasks:
http://jira.jboss.com/jira/browse/JBAOP-500
http://jira.jboss.com/jira/browse/JBAOP-501
The first scenario (JBAOP-500) started happening after bug fix JBAOP-480.
It can be stopped if JBoss AOP starts avoiding to transform the generated joinpoint classes (on class AOPTransformer). For that, simply adding an aop suffix to the generated class name would work.
However, in the second scenario, JBAOP-501, the deadlock can happen when one of the threads executes an AspectManager synchronized operation that needs to load an advisable class, while the other thread starts loading an advisable class. So, the first thread has AspectManager lock but needs the class loader lock, while the second thread has the class loader lock but needs the AspectManager one to try to transform the advisable class.
I have a suggestion to fix this, but I'm not sure it can be applied on the possible scenarios (this info is something we would need to gather).
My idea will work only if we can state that all the advisable instances that JBoss AOP creates during AspectManager synchronized method executions won't be instrumented. If this is true, we can start considering those instances as non-advisable instead of advisable. In this case, we would need to check if the class is advisable at method AspectManager.transform (which is non-synchronized), before calling translate (which is synchronized). This would halt the transformation process on the given deadlock scenarios before acquiring AspectManager lock, avoiding the deadlock.
Using the thread dump scenario provided by Stale as an example (described on task JBAOP-501), the deadlock happens when JBoss AOP loads an Interceptor class to create. In this case can we say that Interceptors shouldn't be instrumented? If we can, we can go for the approach above for this scenario.