From owner-freebsd-bugs Fri Jan 21 0:10: 6 2000 Delivered-To: freebsd-bugs@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 61D681543A for ; Fri, 21 Jan 2000 00:10:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id AAA37332; Fri, 21 Jan 2000 00:10:02 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from tock.gpsclock.com (tock.gpsclock.com [209.133.29.20]) by hub.freebsd.org (Postfix) with ESMTP id B1B2714C43 for ; Fri, 21 Jan 2000 00:07:46 -0800 (PST) (envelope-from davids@tock.gpsclock.com) Received: (from davids@localhost) by tock.gpsclock.com (8.9.3/8.9.3) id AAA14016; Fri, 21 Jan 2000 00:07:45 -0800 (PST) (envelope-from davids) Message-Id: <200001210807.AAA14016@tock.gpsclock.com> Date: Fri, 21 Jan 2000 00:07:45 -0800 (PST) From: davids@webmaster.com Reply-To: davids@webmaster.com To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: misc/16245: libc_r bug in poll, timeout math suspicious Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 16245 >Category: misc >Synopsis: poll misconverts milliseconds to nanoseconds >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Fri Jan 21 00:10:01 PST 2000 >Closed-Date: >Last-Modified: >Originator: David Schwartz >Release: FreeBSD 3.3-STABLE i386 >Organization: Webmaster, Incorporated >Environment: FreeBSD 3.3-STALE system. Using libc_r with loops based heavily around poll with timeouts. >Description: Threaded code that uses libc_r and is based around 'poll' uses much more system CPU time than it should. Problem is tracked to a math error in the 'poll' routine. >How-To-Repeat: Run any program that calls poll in a tight loop, relying on the timeout in 'poll' to prevent a spin. >Fix: In libc_r/uthread/uthread_poll.c, we find the following suspicious math: } else if (timeout > 0) { /* Convert the timeout in msec to a timespec: */ ts.tv_sec = timeout / 1000; ts.tv_nsec = (timeout % 1000) * 1000; /* Set the wake up time: */ _thread_kern_set_timeout(&ts); } else if (timeout < 0) { This conversion from milliseconds to nanoseconds is incorrect. There are a million milliseconds in a nanosecond. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message