From owner-freebsd-ports-bugs@FreeBSD.ORG Mon Nov 2 11:10:04 2009 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4FED51065694 for ; Mon, 2 Nov 2009 11:10:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 2D5CF8FC0A for ; Mon, 2 Nov 2009 11:10:04 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id nA2BA44c035726 for ; Mon, 2 Nov 2009 11:10:04 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id nA2BA4SC035725; Mon, 2 Nov 2009 11:10:04 GMT (envelope-from gnats) Resent-Date: Mon, 2 Nov 2009 11:10:04 GMT Resent-Message-Id: <200911021110.nA2BA4SC035725@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Henry Hu Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2AB510656D3 for ; Mon, 2 Nov 2009 11:08:37 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id A83998FC23 for ; Mon, 2 Nov 2009 11:08:37 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nA2B8bgQ012834 for ; Mon, 2 Nov 2009 11:08:37 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id nA2B8bmn012832; Mon, 2 Nov 2009 11:08:37 GMT (envelope-from nobody) Message-Id: <200911021108.nA2B8bmn012832@www.freebsd.org> Date: Mon, 2 Nov 2009 11:08:37 GMT From: Henry Hu To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/140216: [patch] devel/nspr does not check POLLHUP in PR_ConnectContinue X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Nov 2009 11:10:04 -0000 >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: