pasky / pachi

A fairly strong Go/Baduk/Weiqi playing program
http://pachi.or.cz/
GNU General Public License v2.0
514 stars 117 forks source link

max_tree_size setting interpreted wrong on some platforms #43

Closed avysk closed 6 years ago

avysk commented 8 years ago

uct/internal.h defines max_tree_size as following:

unsigned long max_tree_size;

While on 64-bit Linux unsigned long is 64 bit wide, the standard requires it to be at least 32 bit; and indeed, on some 64-bit platforms (Windows: Visual C or mingw64 in msys2 environment) it's 32 bit only. As a result, the max_tree_size setting, provided in command line, will be taken modulo 4 Gb. In other words, if 64-bit pachi is run with max_tree_size being 4 Gb, it is effectively running with max_tree_size being 0.

The proper fix would be to define max_tree_size as size_t (max_tree_size is passed to malloc2, which is a #define for checked_malloc, which expects size_t).

I don't have a proper understanding of the pachi's code to make a patch immediately; at the first look just changing max_tree_size type opens Pandora box, as there seems to be other stuff which has to be of the same type. And using -Wconversion for the compiler does not help because it produces a zillion of warnings even without this change.

I'll see what I can do, though.

lemonsqueeze commented 6 years ago

Fixed in PR #77 (and windows beta3)