Sebastien GRIMARD created FELIX-3789:
----------------------------------------
Summary: Deadlock due to synchronization on INSTANCE_NAME
Key: FELIX-3789
URL: https://issues.apache.org/jira/browse/FELIX-3789
Project: Felix
Issue Type: Bug
Components: iPOJO
Affects Versions: ipojo-core-1.8.4
Reporter: Sebastien GRIMARD
iPojo sometimes locks up during component instanciation in our application.
After analysis, the lockup occurs since the fix in FELIX-3548 was applied.
The problem is that createComponentInstance in the class IPojoFactory is
pseudo-recursive (through a call to getHandler), that is it can call
recursively itself on a different factory instance.
Since createComponentInstance synchronizes itself on the factory first (local
lock) and on INSTANCE_NAME second (global lock), sometimes it will try to call
createComponentInstance on a different factory while holding the global lock
and while another threads holds that factory's local lock and is trying to
acquire the global lock (I hope what I wrote makes sense).
Stack trace of the problem :
Daemon Thread [Thread-1] (Suspended)
owns: ComponentFactory (id=5717)
owns: ArrayList<E> (id=5708) <==============
owns: HandlerManagerFactory (id=5718)
waiting for: HandlerManagerFactory (id=5709) <==============
HandlerManagerFactory(IPojoFactory).createComponentInstance(Dictionary,
ServiceContext) line: 258
ComponentFactory(IPojoFactory).getHandler(IPojoFactory$RequiredHandler,
ServiceContext) line: 830
ComponentFactory(IPojoFactory).createComponentInstance(Dictionary,
ServiceContext) line: 306
ComponentFactory(IPojoFactory).createComponentInstance(Dictionary)
line: 239
InstanceCreator$ManagedInstance.create(IPojoFactory) line: 343
InstanceCreator.onValidation(IPojoFactory) line: 202
InstanceCreator.stateChanged(Factory, int) line: 243
ComponentFactory(IPojoFactory).computeFactoryState() line: 766
ComponentFactory.addedService(ServiceReference) line: 414
Tracker$Tracked.trackAdding(ServiceReference) line: 725
Tracker$Tracked.track(ServiceReference) line: 686
Tracker$Tracked.serviceChanged(ServiceEvent) line: 642
FilteredServiceListener.serviceChanged(ServiceEvent) line: 107
BundleContextImpl.dispatchEvent(Object, Object, int, Object) line: 861
EventManager.dispatchEvent(Set, EventDispatcher, int, Object) line:
230
ListenerQueue.dispatchEventSynchronous(int, Object) line: 148
ServiceRegistry.publishServiceEventPrivileged(ServiceEvent) line: 819
ServiceRegistry.publishServiceEvent(ServiceEvent) line: 771
ServiceRegistrationImpl.register(Dictionary) line: 130
ServiceRegistry.registerService(BundleContextImpl, String[], Object,
Dictionary) line: 214
BundleContextImpl.registerService(String[], Object, Dictionary) line:
433
HandlerManagerFactory(IPojoFactory).start() line: 613
Extender.createAbstractFactory(Bundle, Element) line: 520
Extender.parse(Bundle, String) line: 301
Extender.startManagementFor(Bundle) line: 237
Extender.access$600(Extender, Bundle) line: 52
Extender$CreatorThread.run() line: 769
Thread.run() line: 662
Daemon Thread [Thread-7] (Suspended)
owns: HandlerManagerFactory (id=5709) <==============
owns: ComponentFactory (id=5710)
owns: Tracker (id=5711)
owns: Dependency[] (id=5712)
waiting for: ArrayList<E> (id=5708) <==============
HandlerManagerFactory(IPojoFactory).createComponentInstance(Dictionary,
ServiceContext) line: 283
ComponentFactory(IPojoFactory).getHandler(IPojoFactory$RequiredHandler,
ServiceContext) line: 830
ComponentFactory(IPojoFactory).computeDescription() line: 721
ComponentFactory(IPojoFactory).computeFactoryState() line: 757
ComponentFactory.addedService(ServiceReference) line: 414
Tracker$Tracked.trackAdding(ServiceReference) line: 725
Tracker$Tracked.trackInitialServices() line: 610
Tracker.open() line: 210
ComponentFactory.starting() line: 262
ComponentFactory(IPojoFactory).start() line: 605
PrimitiveComponentType.createFactory() line: 441
PrimitiveComponentType.initializeFactory() line: 198
PrimitiveComponentType.getFactory() line: 171
PrimitiveComponentType(ComponentType).ensureFactory() line: 185
PrimitiveComponentType(ComponentType).ensureAndGetFactory() line: 177
PrimitiveComponentType(ComponentType).createInstance() line: 79
COI_Starter.__M_coiBuildler(COI_ConfigLoader) line: 176
COI_Starter.coiBuildler(COI_ConfigLoader) line: not available
COI_Starter.__M_startOSGI() line: 97
COI_Starter.startOSGI() line: not available
NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not
available [native method]
NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39
DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25
Method.invoke(Object, Object...) line: 597
Callback.call(Object[]) line: 233
Callback.call() line: 193
LifecycleCallback.call() line: 86
LifecycleCallbackHandler.__M_stateChanged(int) line: 162
LifecycleCallbackHandler.stateChanged(int) line: not available
InstanceManager.setState(int) line: 535
InstanceManager.stateChanged(ComponentInstance, int) line: 1401
HandlerManager(InstanceManager).setState(int) line: 560
HandlerManager.stateChanged(ComponentInstance, int) line: 239
DependencyHandler(Handler).setValidity(boolean) line: 174
DependencyHandler.__M_checkContext() line: 186
DependencyHandler.checkContext() line: not available
DependencyHandler.__M_validate(DependencyModel) line: 149
DependencyHandler.validate(DependencyModel) line: not available
Dependency(DependencyModel).validate() line: 642
Dependency(DependencyModel).computeDependencyState() line: 310
Dependency(DependencyModel).manageArrival(ServiceReference) line: 399
Dependency(DependencyModel).addedService(ServiceReference) line: 335
Tracker$Tracked.trackAdding(ServiceReference) line: 725
Tracker$Tracked.track(ServiceReference) line: 686
Tracker$Tracked.serviceChanged(ServiceEvent) line: 647
FilteredServiceListener.serviceChanged(ServiceEvent) line: 107
BundleContextImpl.dispatchEvent(Object, Object, int, Object) line: 861
EventManager.dispatchEvent(Set, EventDispatcher, int, Object) line:
230
ListenerQueue.dispatchEventSynchronous(int, Object) line: 148
ServiceRegistry.publishServiceEventPrivileged(ServiceEvent) line: 819
ServiceRegistry.publishServiceEvent(ServiceEvent) line: 771
ServiceRegistrationImpl.register(Dictionary) line: 130
ServiceRegistry.registerService(BundleContextImpl, String[], Object,
Dictionary) line: 214
BundleContextImpl.registerService(String[], Object, Dictionary) line:
433
BundleContextImpl.registerService(String, Object, Dictionary) line:
451
IPojoContext.registerService(String, Object, Dictionary) line: 404
StartupSequencerImpl$SequenceThread.launchStartupPhase(StartupPhase)
line: 309
StartupSequencerImpl$SequenceThread.runStartup() line: 389
StartupSequencerImpl$SequenceThread.run() line: 262
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira