[vlc-devel] Incorrect logic in poll causing VLC video freeze and subsequent high CPU utilization.

Tony Anecito adanecito at yahoo.com
Fri Feb 8 21:38:07 CET 2008


Hi VLC Team,

Sorry to bother you but since I was on vacation day
today and while awake (versus groggy at 2-4AM) I
figured out what is happening in VLC code to cause VLC
freezing (under all modes viewing or streaming
server).

Seems the logic for testing the status of the file
descriptors in poll is incorrect for when determining
there is an interrupted socket.

It looks as if you setup in io.c __net_Read() the
descriptor to detect socket error using ufd[1].fd

struct pollfd ufd[2] = {
        { .fd = fd, .events = POLLIN },
        { .fd = -1, .events = POLLIN },
    };

but immediately in io.c __net_Read() use if it:
ufd[1].fd = vlc_object_waitpipe (p_this);
        if (ufd[1].fd == -1)
        {
        }

The test in poll.c poll():

for (unsigned i = 0; i < nfds; i++)
    {
        int fd = fds[i].fd;
        fds[i].revents = (FD_ISSET (fd, &rdset) ?
POLLIN : 0)
                       | (FD_ISSET (fd, &wrset) ?
POLLOUT : 0)
                       | (FD_ISSET (fd, &exset) ?
POLLPRI : 0);

    }

CAUSES ufd[1].revents to be set to NON-ZERO if the
descriptors match regardless of they are vald.

What I found out is that for ufd[1].fd will match and
not be -1 potentially at some point in time.

If the goal is to detect a socket error you need to
verify the fd against -1 which is not done here or
later since by then the value of ufd[1].fd is greater
than zero


Please advise what your recommendations are. For now I
will add a test for -1 using ufd[1].fd since the
following seems to fix the problem for VLC and
propagate the error (-1) when it happens.


For a fix (maybe not THE fix) I added a test in the
poll.c poll() function where I reset the revents for
fds[1] if the ufds[1].fd is not -1.

for (unsigned i = 0; i < nfds; i++)
    {
        int fd = fds[i].fd;
        fds[i].revents = (FD_ISSET (fd, &rdset) ?
POLLIN : 0)
                       | (FD_ISSET (fd, &wrset) ?
POLLOUT : 0)
                       | (FD_ISSET (fd, &exset) ?
POLLPRI : 0);

//NEW ADDITION TO CORRECT VLC FREEZING
		if(fds[i].revents)
		{
			if(fds[1].fd != -1)
			{
				fds[i].revents = 0;
			}
		}
//END OF NEW ADDITION

    }


Thanks,
-Tony



      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ 

_______________________________________________
vlc-devel mailing list
To unsubscribe or modify your subscription options:
http://mailman.videolan.org/listinfo/vlc-devel



More information about the vlc-devel mailing list