OpenHome Forum
Provider update deadlock in DviSubscription::PropertiesInitialised - Printable Version

+- OpenHome Forum (http://forum.openhome.org)
+-- Forum: OpenHome (/forumdisplay.php?fid=1)
+--- Forum: Net (/forumdisplay.php?fid=5)
+--- Thread: Provider update deadlock in DviSubscription::PropertiesInitialised (/showthread.php?tid=1124)



Provider update deadlock in DviSubscription::PropertiesInitialised - lpeter - 03-06-2013 08:56 AM

Hi,

I'm trying to write a simple renderer based on ohNet, but I hit the wall. It locks up after a few seconds after it starts playing a track.
Little debugging showed me that two threads gets in a deadlock. One them is the thread tries to update a provider property from a Timer callback, the other one is ohNet thread that tries to cancel a Timer.

Detailed call stack :

Thread 1: Callback thread from timer already acquired iCallbackMutex in TimerManager and tries to acquire iLock in DviSubscription

Code:
OpenHome::Os::MutexLock(void * aMutex) Line 53     C++
OpenHome::Mutex::Wait() Line 77     C++
OpenHome::Net::DviSubscription::PropertiesInitialised() Line 231     C++
OpenHome::Net::DviSubscriptionManager::QueueUpdate(OpenHome::Net::DviSubscriptio​n & aSubscription) Line 491     C++
OpenHome::Net::DviService::PublishPropertyUpdates() Line 231     C++
OpenHome::Net::DvProvider::TryPublishUpdate() Line 107     C++
OpenHome::Net::DvProvider::SetPropertyUint(OpenHome::Net::PropertyUint & aProperty, unsigned int aValue) Line 63     C++
OpenHome::Net::DvProviderAvOpenhomeOrgTime1::SetPropertySeconds(unsigned int aValue) Line 39     C++
OpenHome::Media::ProviderTime::SetSeconds(unsigned int aSeconds) Line 43     C++

Thread 2: Internal ohNet thread that already acquired iLock in DviSubscription and tries to acquire iCallbackMutex in TimerManager:

Code:
OpenHome::Os::MutexLock(void * aMutex) Line 53     C++
OpenHome::Mutex::Wait() Line 77     C++
OpenHome::TimerManager::CallbackLock() Line 148     C++
OpenHome::Timer::Cancel() Line 74     C++
OpenHome::ReaderHttpResponse::Read(unsigned int aTimeoutMs) Line 479     C++
OpenHome::Net::PropertyWriterUpnp::PropertyWriteEnd() Line 412     C++
OpenHome::Net::DviSubscription::WriteChanges() Line 161     C++
OpenHome::Net::Publisher::Run() Line 389     C++

It is not clear to me weather this az undocumented feature that provider properties should not be updated in a Timer callback, or it is a TimerManager bug...

Br,
Peter


RE: Provider update deadlock in DviSubscription::PropertiesInitialised - simonc - 03-06-2013 03:20 PM

(03-06-2013 08:56 AM)lpeter Wrote:  I'm trying to write a simple renderer based on ohNet, but I hit the wall. It locks up after a few seconds after it starts playing a track.
Little debugging showed me that two threads gets in a deadlock. One them is the thread tries to update a provider property from a Timer callback, the other one is ohNet thread that tries to cancel a Timer.

Thanks for the detailed report!

This was a bug. I hope I've fixed it locally. The changes should make it onto github this evening.


RE: Provider update deadlock in DviSubscription::PropertiesInitialised - lpeter - 05-06-2013 10:54 AM

(03-06-2013 03:20 PM)simonc Wrote:  Thanks for the detailed report!

This was a bug. I hope I've fixed it locally. The changes should make it onto github this evening.

I tested the patch and it fixed the deadlock issue. Thanks.

...strange, but it appeared on github only yesterday evening.


RE: Provider update deadlock in DviSubscription::PropertiesInitialised - simonc - 05-06-2013 10:57 AM

(05-06-2013 10:54 AM)lpeter Wrote:  I tested the patch and it fixed the deadlock issue. Thanks.

Thanks, good to hear its working.

(05-06-2013 10:54 AM)lpeter Wrote:  ...strange, but it appeared on github only yesterday evening.

We run an automated set of builds/tests each evening and only push to github if these pass. We had a problem with our Mac build slave a couple of days ago which caused a build to fail and so the code push to be deferred.