XBMC UPnP leak found!

Posted on September 5, 2006

Finally, this week-end, I was able to find the crazy memory leak that had crippled XBMC. JMarshall was able to constantly reproduce it by connecting his laptop to the same network the xbox was on. Finally, a few ethereal dumps later, I found out that he was running ICS on his laptop and that ICS would respond to the XBMC UPnP M-SEARCH requests that it sends every 6 secs. So it had to be that the response was causing the leak. Of course, somehow it took me 1h to figure out how to set up ICS (you need 2 active network adapters to even see the option in XP!). Even after setting it up, it wouldn’t respond to the M-SEARCH requests for me. Instead, I was able to see what would happen when ICS go alive (and catch the NOTIFY) using the Windows version of Platinum.

After hitting a pretty big race condition bug (2 threads accessing the same device list), I assumed the leak was there. While I was talking to GeminiSer on irc describing what I found, I was also stepping through the code as it was receiving the Device Description and SCPDs and then I saw it. Right there, the leak. Somehow, I made asumptions that the SendEvents attribute in SCPDs was required and was bailing out of my parser when it couldn’t find it. Of course, I was not cleaning up the dom tree in that case!

Now I don’t know if SendEvent is optional but in any case, it’s the first time I see this problem. In any case, the latest xbmc t3ch release is leak free at last!

Leave a Reply