]> git.sesse.net Git - stockfish/commitdiff
Do not initialize RootPosition at startup
authorJoona Kiiski <joona.kiiski@gmail.com>
Tue, 26 Jan 2010 18:22:51 +0000 (20:22 +0200)
committerMarco Costalba <mcostalba@gmail.com>
Wed, 27 Jan 2010 19:00:28 +0000 (20:00 +0100)
Initializing high-level object at startup is very dangerous,
because low-level snippets are not yet initialized.

For example Position's constructor calls find_checkers() which
calls attackers_to() which depends on various global bitboard arrays
which are not yet initialized. I think we are lucky not to crash.

RootPosition.from_fen(StartPosition); is called immediately after
all initializations are made at uci_main_loop() which is the
correct behaviour

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
src/uci.cpp

index 51eb15b671f380d0542880c9c4e200f8a41adf87..6fa55912f7f6761a35f1e35d2f5b9d34560e192c 100644 (file)
@@ -54,7 +54,7 @@ namespace {
   // The root position. This is set up when the user (or in practice, the GUI)
   // sends the "position" UCI command. The root position is sent to the think()
   // function when the program receives the "go" command.
-  Position RootPosition(StartPosition);
+  Position RootPosition;
 
   // Local functions
   bool handle_command(const string& command);