Skip site navigation (1)Skip section navigation (2)
Date:      17 Sep 2002 16:13:34 -0000
From:      Karl Lehenbauer <karl@habitat.procplace.com>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   kern/42875: gettimeofday super rarely returns an impossible tv_usec value
Message-ID:  <20020917161334.20862.qmail@habitat.procplace.com>

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

>Number:         42875
>Category:       kern
>Synopsis:       gettimeofday super rarely returns an impossible tv_usec value
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Sep 17 09:20:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Karl Lehenbauer
>Release:        FreeBSD 4.6-STABLE i386
>Organization:
Procplace.com, Inc.
>Environment:
System: FreeBSD habitat.procplace.com 4.6-STABLE FreeBSD 4.6-STABLE #3: Mon Aug 5 22:36:39 CDT 2002 dbaker@habitat.procplace.com:/usr/local/dbakerspawn/builds/obj/RELENG_4/usr/local/dbakerspawn/RELENG/4/src/sys/2UIAHPROCPLACE i386


	
>Description:
	Maybe one in thirty million times, gettimeofday will return
	an invalid tv_usec value (microseconds).  It should ALWAYS
	be between 0 and 999999, but it is occasionally a very large
	negative number.

>How-To-Repeat:
	Compile this program and let it run for a super long time.
	Preferably use a machine that is actually doing stuff.
	
/* detect freebsd gettimeofday bug */

#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>

check()
{
    struct timeval tv;

    if (gettimeofday(&tv, NULL) == -1) {
	perror("gettimeofday");
	return;
    }

    if (tv.tv_usec < 0 || tv.tv_usec >= 1000000) {
	 printf("cazart!  gettimeofday returned impossible tv_usec value of %d\n", tv.tv_usec);
    }
}

main()
{
    int i;

    for (i = 0; i < 1000000; i++) {
	int j;
	for (j = 0; i < 100; j++) {
	    check();
	}
	usleep((i % 8) + 1);
    }
}
>Fix:

	Locate and repair bug in kernel that allows invalid tv_usec
	calls to be returned.


>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?20020917161334.20862.qmail>