Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Jan 2000 00:07:45 -0800 (PST)
From:      davids@webmaster.com
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   misc/16245: libc_r bug in poll, timeout math suspicious
Message-ID:  <200001210807.AAA14016@tock.gpsclock.com>

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


>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




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