[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freebsd-amd64
Subject:    Re: amd64/109584: zdump doesn't work
From:       Vasil Dimov <vd () freebsd ! org>
Date:       2007-02-28 8:00:21
Message-ID: 200702280800.l1S80LCx094745 () freefall ! freebsd ! org
[Download RAW message or body]

The following reply was made to PR amd64/109584; it has been noted by GNATS.

From: Vasil Dimov <vd@FreeBSD.org>
To: John Baldwin <jhb@freebsd.org>
Cc: freebsd-amd64@freebsd.org, Daniel Crandall <dcrandall@simplestar.com>, \
wollman@freebsd.org, kensmith@freebsd.org, rwatson@freebsd.org, \
                bug-followup@FreeBSD.org
Subject: Re: amd64/109584: zdump doesn't work
Date: Wed, 28 Feb 2007 09:52:44 +0200

 On Wed, Feb 28, 2007 at 08:43:37 +0200, Vasil Dimov wrote:
 [...]
 > it hangs in this loop:
 > 
 > src/lib/libc/stdtime/localtime.c:
 > 1320         y = EPOCH_YEAR;
 > 1321 #define LEAPS_THRU_END_OF(y)    ((y) / 4 - (y) / 100 + (y) / 400)
 > 1322         while (days < 0 || days >= (long) year_lengths[yleap = isleap(y)]) {
 > 1323                 long    newy;
 > 1324
 > 1325                 newy = y + days / DAYSPERNYEAR;
 > 1326                 if (days < 0)
 > 1327                         --newy;
 > 1328                 days -= (newy - y) * DAYSPERNYEAR +
 > 1329                         LEAPS_THRU_END_OF(newy - 1) -
 > 1330                         LEAPS_THRU_END_OF(y - 1);
 > 1331                 y = newy;
 > 1332         }
 > 
 > where days oscillates between -1 and 365, y and newy between
 > -292277022654 and -292277022655. E.g. try so see what happens if you
 > enter the loop with days=365 and y=-292277022655.
 
 What about this patch:
 
 --- localtime.c_infloop.diff begins here ---
 Index: localtime.c
 ===================================================================
 RCS file: /home/ncvs/src/lib/libc/stdtime/localtime.c,v
 retrieving revision 1.41
 diff -u -r1.41 localtime.c
 --- localtime.c	19 Jan 2007 01:16:35 -0000	1.41
 +++ localtime.c	28 Feb 2007 07:40:24 -0000
 @@ -1326,8 +1326,8 @@
  		if (days < 0)
  			--newy;
  		days -= (newy - y) * DAYSPERNYEAR +
 -			LEAPS_THRU_END_OF(newy - 1) -
 -			LEAPS_THRU_END_OF(y - 1);
 +			LEAPS_THRU_END_OF(newy - (newy > 0 ? 1 : -1)) -
 +			LEAPS_THRU_END_OF(y - (y > 0 ? 1 : -1));
  		y = newy;
  	}
  	tmp->tm_year = y - TM_YEAR_BASE;
 --- localtime.c_infloop.diff ends here ---
 
 -- 
 Vasil Dimov
 gro.DSBeerF@dv
 %
 Everything should be made as simple as possible, but not simpler.
                 -- Albert Einstein
_______________________________________________
freebsd-amd64@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-amd64
To unsubscribe, send any mail to "freebsd-amd64-unsubscribe@freebsd.org"


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic