From bin@base486  Thu Oct 19 21:30:14 1995
Received: from base486 ([168.113.1.50])
          by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id VAA15039
          for <FreeBSD-gnats-submit@freebsd.org>; Thu, 19 Oct 1995 21:30:04 -0700
Received: (from bin@localhost) by base486 (8.6.11/8.6.9) id XAA07331; Thu, 19 Oct 1995 23:26:49 -0500
Message-Id: <199510200426.XAA07331@base486>
Date: Thu, 19 Oct 1995 23:26:49 -0500
From: Dave.Bodenstab@base486
Reply-To: imdave@synet.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: getrusage() bug
X-Send-Pr-Version: 3.2

>Number:         788
>Category:       kern
>Synopsis:       getrusage() overflows after ~4000 seconds
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:
>Keywords:
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Oct 19 21:40:01 PDT 1995
>Closed-Date:    Sat Oct 21 02:18:56 PDT 1995
>Last-Modified:  Sat Oct 21 02:20:02 PDT 1995
>Originator:     Dave Bodenstab
>Release:        FreeBSD 2.0-BUILT-19950612 i386
>Organization:
>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;



>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: bde 
State-Changed-When: Sat Oct 21 02:18:56 PDT 1995 
State-Changed-Why:  
Fix applied in rev 1.13 of kern_resource.c. 
>Unformatted:
