gnugo-devel
[Top][All Lists]
Advanced

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

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


From: Lutz Euler
Subject: [gnugo-devel] Bug in cache size calculation in 3.5.4
Date: Sat, 24 Jan 2004 20:01:27 +0100

Hi,

I just downloaded version 3.5.4, configured it with my usual
settings containing "--enable-cache-size=32", compiled and
started it, just to get the following error:

Couldn't allocate memory for transposition table. 
: Cannot allocate memory

This is on an x86 linux box, kernel 2.2.16, gcc 3.3, with more
than 1.5 GB of virtual memory available.

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 ;-)

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?

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

Yours

Lutz Euler




reply via email to

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