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] [Updated] (FELIX-4523) Deadlock in URLHandlers when Felix.init and Felix.stop are called concurrently
Date Fri, 04 Jul 2014 17:02:33 GMT

     [ https://issues.apache.org/jira/browse/FELIX-4523?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Benjamin Rogge updated FELIX-4523:

    Attachment: ConcurrentTest.java

I extended the test. The test fails, if there is a deadlock situation, however provoking a
deadlock in a reproducible and predictable manner  is in this case rather difficult. (There
also is the way of making the testcase more efficient by using the ThreadMXBean, but that
basically means, implementing a full deadlock recognition)

While without the patch, the test ran into a deadlock about 3/4 of the runs, after the patch,
I could not observe the deadlock anymore. So, the deadlock should be fixed. Looking forward
to the new version :-)

> 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

View raw message