Opened 5 years ago

Closed 5 years ago

#12395 closed Bug Report - General (fixed)

SSDP thread uses 100% CPU

Reported by: Warren Falk <warren@…> Owned by: stuartm
Priority: critical Milestone: 0.27.5
Component: MythTV - UPnP Version: 0.27-fixes
Severity: high Keywords:
Cc: Ticket locked: no

Description

On both backend and frontend, the SSDP thread after a few minutes or hours will jump to 100% CPU and never come down.

I discovered this to be caused by a zero byte UDP packet (that some badly designed UPNP device on my network must be sending).

This can be reproduced using the following C program:

#include <sys/socket.h>
#include <netinet/in.h>
#include <string.h>
#include <stdio.h>

int main(int argc, char**argv)
{
   int sockfd,n;
   struct sockaddr_in servaddr,cliaddr;
   char sendline[0];

   sockfd=socket(AF_INET,SOCK_DGRAM,0);

   bzero(&servaddr,sizeof(servaddr));
   servaddr.sin_family = AF_INET;
   servaddr.sin_addr.s_addr=inet_addr("239.255.255.250");
   servaddr.sin_port=htons(1900);

   int len = 0;
   printf("Send %d bytes\n", len);
   sendto(sockfd,sendline,len,0,(struct sockaddr *)&servaddr,sizeof(servaddr));
}

And then running the following (on the backend, just for example)

top -H -p `pgrep mythbackend`

Change History (5)

comment:1 Changed 5 years ago by Warren Falk <warren@…>

I have a fork of fixes/0.27 and have coded a fix which works. I will create a pull request, but I've never submitted code to the project before.

I cannot easily test on master because this installation is currently in use. I believe the problem still exists there, and should be easily reproducible using the file in the description.

The requirements for submitting tickets and code to this project are pretty daunting for a first timer. Take it easy on me.

comment:2 Changed 5 years ago by stuartm

Milestone: unknown0.27.5
Owner: changed from dblain to stuartm
Priority: minorcritical
Severity: mediumhigh
Status: newaccepted

comment:3 Changed 5 years ago by Stuart Auchterlonie

There's an open pull request for this https://github.com/MythTV/mythtv/pull/92

comment:4 Changed 5 years ago by Warren Falk <warren@…>

In 628183a01b66a010e9cf510b9d1d08a348ed5889/mythtv:

fix SSDP thread using 100% CPU on zero byte datagrams

Refs #12395

Signed-off-by: Stuart Morgan <smorgan@…>

comment:5 Changed 5 years ago by Warren Falk <warren@…>

Resolution: fixed
Status: acceptedclosed

In 4adfeffe264a67425f459c5b76cfce79a29db356/mythtv:

fix SSDP thread using 100% CPU on zero byte datagrams

Fixes #12395

Signed-off-by: Stuart Morgan <smorgan@…>

Note: See TracTickets for help on using tickets.