Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Oct 1995 23:26:49 -0500
From:      Dave.Bodenstab@base486
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/788: getrusage() bug
Message-ID:  <199510200426.XAA07331@base486>
Resent-Message-ID: <199510200440.VAA15210@freefall.freebsd.org>

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

>Number:         788
>Category:       kern
>Synopsis:       getrusage() overflows after ~4000 seconds
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 19 21:40:01 PDT 1995
>Last-Modified:
>Originator:     Dave Bodenstab
>Organization:
>Release:        FreeBSD 2.0-BUILT-19950612 i386
>Environment:

	6/22 snap

>Description:

	getrusage() overflows after about 4000 seconds.  The multiplication
	of sec * 1000000 uses unsigned longs -- not unsiged quads -- and
	therefore overflows at 2^32/1000000 seconds.

>How-To-Repeat:

	run rayshade with an interesting scene file.  :-)

>Fix:
	

*** kern_resource.c.orig	Tue May 30 03:05:39 1995
--- kern_resource.c	Thu Oct 19 20:17:42 1995
***************
*** 487,493 ****
  		sec += tv.tv_sec - runtime.tv_sec;
  		usec += tv.tv_usec - runtime.tv_usec;
  	}
! 	u = sec * 1000000 + usec;
  	st = (u * st) / tot;
  	sp->tv_sec = st / 1000000;
  	sp->tv_usec = st % 1000000;
--- 487,493 ----
  		sec += tv.tv_sec - runtime.tv_sec;
  		usec += tv.tv_usec - runtime.tv_usec;
  	}
! 	u = (u_quad_t) sec * 1000000 + usec;
  	st = (u * st) / tot;
  	sp->tv_sec = st / 1000000;
  	sp->tv_usec = st % 1000000;



>Audit-Trail:
>Unformatted:



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