gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] Bug in cache size calculation in 3.5.4


From: Inge Wallin
Subject: Re: [gnugo-devel] Bug in cache size calculation in 3.5.4
Date: Sun, 25 Jan 2004 00:26:15 +0100 (CET)

 
Hi Lutz, and thank you for the bug report.

On Sat, 24 Jan 2004, Lutz Euler wrote:

> The reason is that the multiplication in
> 
> tt_init(&ttable, bytes * NG_PERCENTAGE / 100);
> 
> in "reading_cache_init" in "engine/cache.c" overflows for cache
> sizes above approximately 21 MB. "tt_init" then gets called with
> a wrong value. In my case this value is -11072962 which results
> in malloc being called with its argument being 4283894328.
> I doubt that on a 32-bit OS such a call could succeed even if
> I had that much virtual memory available ;-)

This is a good analysis of the bug.  Thank you again.
>
> I worked around that by doing the multiplication and division using
> gcc's "unsigned long long" 64-bit integer type. Maybe doing the
> calculation using floats would be more portable?

The simplest way is to just switch the multiplication and the division so 
that the middle result never overflows.  This is now fixed in the CVS (by 
Gunnar).

> I would have sent a patch but I don't know which way of fixing this
> you prefer.

We are of course greatful for patches, but if all bug reports were this 
good, we wouldn't mind either. :-)


Best regards,

Inge Wallin


-- 
Inge Wallin               | Thus spake the master programmer:               |
                          |      "After three days without programming,     |
address@hidden       |       life becomes meaningless."                |
                          | Geoffrey James: The Tao of Programming.         |





reply via email to

[Prev in Thread] Current Thread [Next in Thread]