Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Nov 2009 11:08:37 GMT
From:      Henry Hu <henry.hu.sh@gmail.com>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/140216: [patch] devel/nspr does not check POLLHUP in PR_ConnectContinue
Message-ID:  <200911021108.nA2B8bmn012832@www.freebsd.org>
Resent-Message-ID: <200911021110.nA2BA4SC035725@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         140216
>Category:       ports
>Synopsis:       [patch] devel/nspr does not check POLLHUP in PR_ConnectContinue
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 02 11:10:03 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Henry Hu
>Release:        FreeBSD 8.0-RC2
>Organization:
Tsinghua University, Beijing
>Environment:
FreeBSD henryhu 8.0-RC2 FreeBSD 8.0-RC2 #1: Sat Oct 31 15:58:01 CST 2009     root@henryhu:/usr/obj/usr/src/sys/MYKERNEL  i386

>Description:
After upgrading to 8.0-RC2, I found firefox using 100% of one CPU core.
The problem appears if I use one PAC file to configure proxy, and it returns "localhost:8119".
Later, I found that firefox tried to connect to ::1:8119 first. Since the proxy listens on 127.0.0.1:8119, it fails with a connection reset. However, firefox continues to poll the file descriptor.
After enabling the debug flag, firefox abort() with an assertion failure in nspr mozilla/nsprpub/pr/src/pthreads/ptio.c:1626, which asserts out_flags to be 0. However, out_flags is PR_POLL_HUP, which means the socket is disconnected. Without the debug flag enabled, the function sets error to PR_IN_PROGRESS_ERROR, and returns. I think firefox keeps polling the fd since it is the "in progress" error.
After patching the function to check PR_POLL_HUP, the problem disappeared. The code after it checks for connection error, which sets the error to the right value, and firefox realizes the real condition.
I can't explain why this problem did not appear while I was using 7.2-STABLE.
>How-To-Repeat:
1. Install FreeBSD 8.0-RC2
2. Install firefox 3.5
3. Install foxyproxy
4. Use a PAC file, contains

function FindProxyForURL(url, host)
{
return "PROXY localhost:8119";
}

5. Try to navigate somewhere
>Fix:
Apply the following patch to devel/nspr

Patch attached with submission follows:

--- work/nspr-4.8/mozilla/nsprpub/pr/src/pthreads/ptio.c.orig	2009-11-02 18:49:10.000000000 +0800
+++ work/nspr-4.8/mozilla/nsprpub/pr/src/pthreads/ptio.c	2009-11-02 18:49:34.000000000 +0800
@@ -1621,6 +1621,7 @@
         PR_SetError(PR_BAD_DESCRIPTOR_ERROR, 0);
         return PR_FAILURE;
     }
+	if ((out_flags & PR_POLL_HUP) == 0)
     if ((out_flags & (PR_POLL_WRITE | PR_POLL_EXCEPT | PR_POLL_ERR)) == 0)
     {
         PR_ASSERT(out_flags == 0);


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911021108.nA2B8bmn012832>