felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karl Pauls (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FELIX-4523) Deadlock in URLHandlers when Felix.init and Felix.stop are called concurrently
Date Tue, 24 Jun 2014 14:58:24 GMT

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

Karl Pauls commented on FELIX-4523:

[~plastic-karma] cool. Please note, I uploaded a slightly modified patch (urlhandlers-2.patch).
Please use that one for your testing. Looking forward to hear if it helps. Furthermore, if
you manage to get this captured in reproducible test case that would be even better :-). 

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