felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benjamin Rogge (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (FELIX-4523) Deadlock in URLHandlers when Felix.init and Felix.stop are called concurrently
Date Thu, 03 Jul 2014 15:38:26 GMT

    [ https://issues.apache.org/jira/browse/FELIX-4523?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14051589#comment-14051589
] 

Benjamin Rogge edited comment on FELIX-4523 at 7/3/14 3:38 PM:
---------------------------------------------------------------

I added a first version of a "unittest" that resembles the deadlock behavior. It does not
check anything (yet), but the testcase will be stuck in a deadlock. I hope this is useful
to you already. I will check the patch with the test as well as our codebase until monday.


was (Author: plastic-karma):
This is a first version of a "unittest" that resembles the deadlock behavior. It does not
check anything (yet), but the testcase will be stuck in a deadlock

> Deadlock in URLHandlers when Felix.init and Felix.stop are called concurrently
> ------------------------------------------------------------------------------
>
>                 Key: FELIX-4523
>                 URL: https://issues.apache.org/jira/browse/FELIX-4523
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: framework-4.2.1
>         Environment: linux, junittests
>            Reporter: Benjamin Rogge
>            Assignee: Karl Pauls
>         Attachments: ConcurrentTest.java, urlhandlers-2.patch, urlhandlers.patch
>
>
> From time to time we are experiencing a deadlock in the URLHandlers Class in Apache Felix.
We are using Felix as an embedded OSGi Container and instantiate the Felix Framework via ServiceLoader
and Framework Factory ourselves. The situation is as follows: When Felix.stop and Felix.init
are called by different threads, eventually URLHandlers.unregisterFrameworkListsForContextSearch
and URLHandlers.registerFrameworkInstance are called by the threads. There are two locks:
m_frameworks and the Class Object of URL (URL.class). registerFrameworkInstance tries to aquire
m_frameworks first and via the constructor of URLHanders URL.class after that. unregisterFrameworkListsForContextSearch
tries to aquire URL.class first and m_frameworks after that. This is a classic deadlock situation.
The situation arises in unittests where we frequently start and stop the felix framework.

> Stacktracke log:
> {code}
> Found one Java-level deadlock:
> =============================
> "FelixShutdown":
>   waiting to lock monitor 0x0000000000ff7710 (object 0x00000007ff33e7f0, a java.util.ArrayList),
>   which is held by "main"
> "main":
>   waiting to lock monitor 0x00000000022c4a08 (object 0x0000000783b06b18, a java.lang.Class),
>   which is held by "FelixShutdown"
> Java stack information for the threads listed above:
> ===================================================
> "FelixShutdown":
> 	at org.apache.felix.framework.URLHandlers.unregisterFrameworkListsForContextSearch(URLHandlers.java:315)
> 	- waiting to lock <0x00000007ff33e7f0> (a java.util.ArrayList)
> 	- locked <0x00000007ff33e840> (a java.util.HashMap)
> 	- locked <0x0000000783b06b18> (a java.lang.Class for java.net.URL)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:606)
> 	at org.apache.felix.framework.util.SecureAction.invoke(SecureAction.java:840)
> 	at org.apache.felix.framework.URLHandlers.unregisterFrameworkInstance(URLHandlers.java:635)
> 	at org.apache.felix.framework.URLHandlersActivator.stop(URLHandlersActivator.java:76)
> 	at org.apache.felix.framework.util.SecureAction.stopActivator(SecureAction.java:667)
> 	at org.apache.felix.framework.Felix$SystemBundleActivator.stop(Felix.java:4715)
> 	at org.apache.felix.framework.util.SecureAction.stopActivator(SecureAction.java:667)
> 	at org.apache.felix.framework.Felix.stopBundle(Felix.java:2530)
> 	at org.apache.felix.framework.Felix$2.run(Felix.java:959)
> 	at java.lang.Thread.run(Thread.java:724)
> "main":
> 	at org.apache.felix.framework.URLHandlers.<init>(URLHandlers.java:150)
> 	- waiting to lock <0x0000000783b06b18> (a java.lang.Class for java.net.URL)
> 	at org.apache.felix.framework.URLHandlers.registerFrameworkInstance(URLHandlers.java:600)
> 	- locked <0x00000007ff33e7f0> (a java.util.ArrayList)
> 	at org.apache.felix.framework.URLHandlersActivator.start(URLHandlersActivator.java:71)
> 	at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
> 	at org.apache.felix.framework.Felix$SystemBundleActivator.start(Felix.java:4634)
> 	at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:645)
> 	at org.apache.felix.framework.Felix.init(Felix.java:783)
> {code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Mime
View raw message