![]() |
Device stack crashes when network adapter disabled - Printable Version +- OpenHome Forum (http://forum.openhome.org) +-- Forum: OpenHome (/forumdisplay.php?fid=1) +--- Forum: Net (/forumdisplay.php?fid=5) +--- Thread: Device stack crashes when network adapter disabled (/showthread.php?tid=492) |
Device stack crashes when network adapter disabled - simoncn - 30-08-2011 09:57 PM If the device stack is started (idle) and the network adapter that it's using is disabled, the stack crashes. It should be able to survive an adapter disable/enable sequence. I found the following three problems and fixed them. With these changes, the adapter can be disabled and re-enabled with the stack still continuing to work afterwards. 1) There's a recursive mutex lock assertion failure when deleting the disabled adapter. The code in NetworkAdapterList::HandleInterfaceListChanged locks the mutex iListLock at the start and is still holding this lock when it executes the following code: Code: if (subnetsChanged) { I fixed this by moving the code: Code: DestroySubnetList(iSubnets); 2. When SocketUdpMulticast::~SocketUdpMulticast() calls OpenHome::Os::NetworkSocketMulticastDropMembership, the latter method throws a NetworkError which isn't handled anywhere in the call stack. This causes the process to exit. I fixed this by adding a try/catch for this exception around the call from ~SocketUdpMulticast(). As the socket's being destroyed anyway, this network error shouldn't matter. Here's the code: Code: SocketUdpMulticast::~SocketUdpMulticast() 3. In DviServer::SubnetListChanged, there's a minor problem with signed/unsigned integers. For the loops that decrement the index, the index variable needs to be signed to ensure correct termination of the loop when the index variable decreases from 0 to -1. In the following code, I have changed the lines marked with **: Code: if (current != NULL) { RE: Device stack crashes when network adapter disabled - simonc - 01-09-2011 01:52 PM Thanks for such a detailed set of reports! I've committed all 3 fixes so they'll hopefully make it onto github this evening. Subnet changing is a known area of weakness - we have a test for the control point stack but it isn't included in automated tests and still need to write a test covering the device stack. That said, you've possibly just flushed out all the bugs these tests would have found :-). RE: Device stack crashes when network adapter disabled - simoncn - 02-09-2011 01:56 PM (01-09-2011 01:52 PM)simonc Wrote: Thanks for such a detailed set of reports! I've committed all 3 fixes so they'll hopefully make it onto github this evening. Test cases are important, but they never catch everything! It wouldn't be very easy to have an automated test for disabling an adapter. I found these problems by noticing that suspending and resuming my laptop caused the device stack to crash ![]() |