From owner-freebsd-bugs@FreeBSD.ORG Mon Jun 7 12:10:07 2010 Return-Path: Delivered-To: freebsd-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 E13C6106567A for ; Mon, 7 Jun 2010 12:10:07 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (unknown [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id BF9998FC21 for ; Mon, 7 Jun 2010 12:10:07 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o57CA3r4065014 for ; Mon, 7 Jun 2010 12:10:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o57CA3FR065013; Mon, 7 Jun 2010 12:10:03 GMT (envelope-from gnats) Resent-Date: Mon, 7 Jun 2010 12:10:03 GMT Resent-Message-Id: <201006071210.o57CA3FR065013@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Martin Simmons Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AC0231065678 for ; Mon, 7 Jun 2010 12:00:55 +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 9BB388FC33 for ; Mon, 7 Jun 2010 12:00:55 +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 o57C0tKa097822 for ; Mon, 7 Jun 2010 12:00:55 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o57C0tcF097821; Mon, 7 Jun 2010 12:00:55 GMT (envelope-from nobody) Message-Id: <201006071200.o57C0tcF097821@www.freebsd.org> Date: Mon, 7 Jun 2010 12:00:55 GMT From: Martin Simmons To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: kern/147647: select wakes after 24 hours even if timeout is longer X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Jun 2010 12:10:08 -0000 >Number: 147647 >Category: kern >Synopsis: select wakes after 24 hours even if timeout is longer >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Jun 07 12:10:03 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Martin Simmons >Release: 8.0-RELEASE-p2 >Organization: >Environment: FreeBSD lwfs1-cam.cam.lispworks.com 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #0: Tue Jan 5 21:11:58 UTC 2010 root@amd64-builder.daemonology.net:/usr/obj/usr/src/sys/GENERIC amd64 >Description: The select system call wakes indicating timeout after 24 hours even if the timeout specifies a longer delay. >How-To-Repeat: Running the code below with argument 10000000 exits after 24 hours with: res = 0 delay = 86398 fd = 3, fd active = 0 #include #include #include #include #include int main(int argc, char **argv) { fd_set fdset; struct timeval tv; int fds[2], fd, res; time_t start, end; pipe(fds); fd = fds[0]; tv.tv_sec = atoi(argv[1]); tv.tv_usec = 0; FD_ZERO(&fdset); FD_SET(fd, &fdset); start = time(NULL); res = select(fd + 1, &fdset, NULL, NULL, &tv); end = time(NULL); printf("res = %d delay = %ld fd = %d, fd active = %d\n", res, (long)(end - start), fd, FD_ISSET(fd, &fdset)); return 0; } >Fix: I think the problem is that seltdwait is implemented using cv_timedwait_sig, which returns EWOULDBLOCK on timeout. The calls to seltdwait in kern_select etc limit the timeout to a maximum of 24 * 60 * 60 * hz but interpret EWOULDBLOCK as a reason to exit rather than checking the actual timeout. >Release-Note: >Audit-Trail: >Unformatted: