EGBB implementation

Discussion of chess software programming and technical issues.

Moderators: hgm, Harvey Williamson, bob

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
Desperado
Posts: 638
Joined: Mon Dec 15, 2008 10:45 am

EGBB implementation

Post by Desperado » Thu Sep 24, 2009 4:21 pm

Hi everyone.

Today i decided to give it a try(egbbs) :).
And of course, nothing was working at first :D.

1. INFO
======
OS: vista 64 + MS VS 2008 (ver 9)
: downloaded latest dlls (egbbdll.dll,egbbdll32.dll,egbbdll64.dll)
: + bitbases

2. FIRST RESULTS
=============

I found a thread on this site somewhere, where an _easy_ description
could be seen.(doesnt work).
I decided downloading Toga,DeepLearningToga to know what
i was doing wrong. To my surprise, both also couldnt load the bitbases!
(found somewhere on the web,that DLT had fixed a bug(on egbb),
which seemed to be in toga.That s why i additionally downloaded DLT).

i was checking the following stuff:

-correct path
-correct implementation of path (slash issues)
-latest known dlls and data
-Loadlibrary issues
... and some other things

before i found out:

3. working for MSVS 2008
==================

- Loadlibrary only seems to work proper if
Unicode-compilation is off (project-properties)!

- egbbdll.dll + egbb32dll.dll only will be loaded on release 32bit compile
- egbbdll64.dll works for release 64bit compile
- in debug mode _only_ egbbdll64.dll can be loaded.

Easy if someone knows, but 3 hours of work for me :(

Hope it can/will help if someone get started with this...

Finally, one question is running through my brain.

The debug-mode seems to use 64bit-compile by default ?!.
Does that depend on OS, or are there other reasons why
in the debug-mode only the egbbdll64.dll can be loaded?
(Well, i just want to point out, that i think it is possible
that for example on a WinXp-system, the debug-mode will
only load the egbbdll.dll and ebggdll32.dll ??!)

Michael

User avatar
Desperado
Posts: 638
Joined: Mon Dec 15, 2008 10:45 am

Re: EGBB implementation

Post by Desperado » Fri Sep 25, 2009 10:24 am

:(

All seemed to be fine, until i found a first and a second position
where my program suddenly crashed.

I began to fix the problems and now I definitely found out
what happens. But i cannot solve the problem. So i think i need help.

found 2 positions leading to a crash, within my search.
Selected the position, but then all was fine until...

After checking my iternals i fixed the input for the egbb-probe function.

fixed input:
col = white;
p[0]=6;
p[1]=4;
p[2]=6;
s[0]=17;
s[1]=27;
s[2]=45;
pwk =9;
pbk =30; //all was running fine

fixed input:
col = black;
p[0]=6;
p[1]=4;
p[2]=6;
s[0]=17;
s[1]=27;
s[2]=45;
pwk =9;
pbk =30; //all was running fine

fixed input with dynamic _colorToMove_:

col = white/black;(brd->ctm)
p[0]=6;
p[1]=4;
p[2]=6;
s[0]=17;
s[1]=27;
s[2]=45;
pwk =9;
pbk =30; // !unpredictable error occurs!

Because i dont have any kind of multithreading, i cannot explain
what is happening. But I am sure, the problem is caused through
the dll-file,or by communication.
(i was making sure,that there arent any type-casting problems for
the input)

The error message was:

"Zugriffsverletzung beim Lesen an Position 0x00000003f40262a4."
i would translate:
access-error on reading position 0x00...

when calling the probe-egbb-function of the dll.

Some hints ?

Michael

User avatar
Desperado
Posts: 638
Joined: Mon Dec 15, 2008 10:45 am

Re: EGBB implementation

Post by Desperado » Fri Sep 25, 2009 10:44 am

PS:

Do i have to handle the call in a multi-Thread manner ?

(or is my application trying to continue what it is doing,
so doesnt wait for the answer of the dll-call automatically?)

User avatar
Eelco de Groot
Posts: 4058
Joined: Sun Mar 12, 2006 1:40 am
Location: Groningen

Re: EGBB implementation

Post by Eelco de Groot » Fri Sep 25, 2009 1:29 pm

Desperado wrote: The error message was:

"Zugriffsverletzung beim Lesen an Position 0x00000003f40262a4."
i would translate:
access-error on reading position 0x00...

when calling the probe-egbb-function of the dll.

Some hints ?

Michael
Hello Michael,

I don't know much about it but, from reading the forum I think it is likely there are problems at the .dll end too so debugging your program may lead you in the wrong direction. I would suggest going back to the older versions of the .dll. Which one is the most stable I am not completely sure. Those old builds are 32 bit dlls which do not work under Vista 64 bits, as far as I know.

You can not read the bitbases with them at least you could not with any Toga build that I know of. Maybe Denis Mendoza can tell you if the 64 bits version of the older egbbdll.dll is better, I just don't know.

But with building from the source of the latest provided by Daniel Shawul, Volker Pittlik reported problems on the Winboard forum. That was several months ago.
Volker Pittlik wrote:
Daniel Shawul wrote:... Anyway try to include the following headers in "common.h" and see what happens...
It was leading to a similar error (something else was undefined). I noticed "common.h" was not included in cache.h. I did so but now I get:

Code: Select all

volker@vpittlik:~/schach/scorpio/egbb33/egbbdll$ make clean; make
rm -rf egbbdll.o moves.o index_new.o decompress.o codec.o cache.o
g++ -O3  -c -fPIC egbbdll.cpp
g++ -O3  -c -fPIC moves.cpp
g++ -O3  -c -fPIC index_new.cpp
g++ -O3  -c -fPIC decompress.cpp
g++ -O3  -c -fPIC codec.cpp
g++ -O3  -c -fPIC cache.cpp
In file included from cache.h:5,
                 from cache.cpp:1:
common.h:250: Fehler: »INFO« bezeichnet keinen Typ
common.h:347: Fehler: »LRU_CACHE« bezeichnet keinen Typ
make: *** [cache.o] Fehler 1
saying "INFO" and "LRU_CACHE" are no types. It's getting a bit confusing now.

Regards
vp
Maybe a cross-post in the Winboard forum will get Daniel's attention or maybe you can exchange some experiences with Volker!

Regards,
Eelco
Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it.
-- Brian W. Kernighan

User avatar
Desperado
Posts: 638
Joined: Mon Dec 15, 2008 10:45 am

Re: EGBB implementation

Post by Desperado » Fri Sep 25, 2009 8:44 pm

Hello Eelco,

thx for reply first.

Well, the only issue to load the dll proper was the problem
with the Unicode compilation.

- no problems with 32dll (32bit-mode) (Vista64!)
- no problems with 64dll (64bit-mode)

- all in all no problems with 4men bitbases (so far).
- 5men work (with exceptions!)

Analyse:

1. i exclude a corrupted bitbase file as reason, because
i always put (constant input) the same data to the probeFunction.
This input i checked for both colors, working fine.(but calling it
more than twice of course).

2. i am not sure about exe/dll communication, can there be
similar problems like in multithreaded applications, so
broken data and so on...
From my point of view, i would exclude this point too, because
at least my exe is single-threaded.

3. I was thinking, my cachesize would be to small (i really tried a
lot of things, which could be gone wrong in my code).
Also excluded this point, because of the next one.

4. only changing the color dynamic, there are for example 9x correct
accesses (for both colors) and then the exception (on the same
input !!!)

At least the last point tells me it has something to do with the dllFile.
How can a more or less constant input work 100x and then for one
reason not ?

Michael

User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 9:44 am
Location: Madrid - Spain
Contact:

Re: EGBB implementation

Post by Kempelen » Thu Oct 22, 2009 8:53 am

Desperado wrote::(

All seemed to be fine, until i found a first and a second position
where my program suddenly crashed.

I began to fix the problems and now I definitely found out
what happens. But i cannot solve the problem. So i think i need help.

found 2 positions leading to a crash, within my search.
Selected the position, but then all was fine until...

After checking my iternals i fixed the input for the egbb-probe function.

fixed input:
col = white;
p[0]=6;
p[1]=4;
p[2]=6;
s[0]=17;
s[1]=27;
s[2]=45;
pwk =9;
pbk =30; //all was running fine

fixed input:
col = black;
p[0]=6;
p[1]=4;
p[2]=6;
s[0]=17;
s[1]=27;
s[2]=45;
pwk =9;
pbk =30; //all was running fine

fixed input with dynamic _colorToMove_:

col = white/black;(brd->ctm)
p[0]=6;
p[1]=4;
p[2]=6;
s[0]=17;
s[1]=27;
s[2]=45;
pwk =9;
pbk =30; // !unpredictable error occurs!

Because i dont have any kind of multithreading, i cannot explain
what is happening. But I am sure, the problem is caused through
the dll-file,or by communication.
(i was making sure,that there arent any type-casting problems for
the input)

The error message was:

"Zugriffsverletzung beim Lesen an Position 0x00000003f40262a4."
i would translate:
access-error on reading position 0x00...

when calling the probe-egbb-function of the dll.

Some hints ?

Michael
I have the same problem as you. I suspect is a windows-vista issue.... does anybody got it to work?
Fermin Serrano
Author of 'Rodin' engine
http://sites.google.com/site/clonfsp/

User avatar
Desperado
Posts: 638
Joined: Mon Dec 15, 2008 10:45 am

Re: EGBB implementation

Post by Desperado » Thu Oct 22, 2009 1:27 pm

Kempelen wrote: I have the same problem as you. I suspect is a windows-vista issue.... does anybody got it to work?
:shock: :lol:

Hi Fermin,

what exactly is your _same_ problem ? To get it to work in general
or the craches the dll is producing (only 5men problems or additionally
4men) ?

are you talking of vista32 or vista64 ?

Michael

User avatar
Kempelen
Posts: 620
Joined: Fri Feb 08, 2008 9:44 am
Location: Madrid - Spain
Contact:

Re: EGBB implementation

Post by Kempelen » Thu Oct 22, 2009 4:52 pm

Desperado wrote:
Kempelen wrote: I have the same problem as you. I suspect is a windows-vista issue.... does anybody got it to work?
:shock: :lol:

Hi Fermin,

what exactly is your _same_ problem ? To get it to work in general
or the craches the dll is producing (only 5men problems or additionally
4men) ?

are you talking of vista32 or vista64 ?

Michael
Hi Michael,

my problem is that it looks to work perfect, but when a few nodes has been searched it crash. My debugger points the bug into eggbbdll.dll.

I have downloaded 4 men bb, but I have problems to run it. It crash when loadlibrary, but I think I need to change something there. I dont know if these lines are correct or I have to change them:

Code: Select all

    load_egbb = (PLOAD_EGBB) GetProcAddress(hmod,"load_egbb_5men");
    probe_egbb = (PPROBE_EGBB) GetProcAddress(hmod,"probe_egbb_5men");
can you point how can I run only 4 men bb?

Best regards,
FS
Fermin Serrano
Author of 'Rodin' engine
http://sites.google.com/site/clonfsp/

User avatar
Desperado
Posts: 638
Joined: Mon Dec 15, 2008 10:45 am

Re: EGBB implementation

Post by Desperado » Thu Oct 22, 2009 5:56 pm

Code: Select all

	//**************************************
	//*	LOCAL DATA						   *
	//**************************************

	enum {_EMPTY,
		  _WKING,_WQUEEN,_WROOK,_WBISHOP,_WKNIGHT,_WPAWN,
		  _BKING,_BQUEEN,_BROOK,_BBISHOP,_BKNIGHT,_BPAWN
		 };

	enum {LOAD_NONE,LOAD_4MEN,SMART_LOAD,LOAD_5MEN};

	const int loadtype = LOAD_4MEN;

...

Code: Select all

//****************************************************************************
//* FUNCTION	: loadEgbbLib()												 *
//* DESCRIPTION	:															 *
//****************************************************************************

static int loadEgbbLib(char *mainpath,UI_32 cachesize)
	{
	 static HINSTANCE hmod;
	 PLOAD_EGBB loadegbb;
	 char path[256]={'\0'};

	 strcpy(path,mainpath);
	 strcat(path,EGBB_NAME);

	 if(hmod) FreeLibrary(hmod);

	 if(hmod = LoadLibrary((path)))
		{
		 loadegbb  = (PLOAD_EGBB)  GetProcAddress(hmod,"load_egbb_5men");
		 probe_egbb= (PPROBE_EGBB) GetProcAddress(hmod,"probe_egbb_5men");

		 //HERE LOADTYPE IS (SHOULD BE) LOAD_4MEN
		 loadegbb(mainpath,cachesize,loadtype);

		 return(egbbLoaded = true);
		}

	 return (egbbLoaded = false);
	}
Further i only probed when my brd->mat->total<=4 condition was kept.
(only to be absolutely sure that i only probe 4men positions)

So, with these settings everything was ok (on vista64!,Unicode-Compilation off).

Only with 5men, i got the access-violation in some rare cases, but
then the program crashed.

cheers, Michael

Daniel Shawul
Posts: 3593
Joined: Tue Mar 14, 2006 10:34 am
Location: Ethiopia
Contact:

Re: EGBB implementation

Post by Daniel Shawul » Thu Oct 22, 2009 6:15 pm

Hello Michael
I work with an old MS compiler VC 1998 so it is a given that it will have some issues with the new compilers. I have windows vista and xp 32 bit here where scoprio uses them with no problem. So does bright and toga. I don't know what new issues will arise in 64 bit mode other than compiling a new dll for the specific platform. One thing that I am aware of is for linux 64 bit, there could be a segmentation fault due to a bug i introduced . See the FAQ i put up here http://sites.google.com/site/dshawul/home . Use the exes from Jim Ablet that i put up there which work for 32/64 bit windows. I will try to work on it using vc2008 and see if i get the same problems that you reported.
thanks,
Daniel

Post Reply