Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Is this a compiler bug?

Author: José Carlos

Date: 08:12:50 10/25/03

Go up one level in this thread


On October 25, 2003 at 09:49:58, Tord Romstad wrote:

>I use the gcc (version 3.2) included with the Cygwin tools to compile the
>Windows version
>of my engine.  The last month or so, the Windows version has had a mysterious
>problem:
>When compiled with the -fbranch-prediction flag, it consistently crashed at move
>109 or
>110 when running in UCI mode.  The problem never occured in Winboard mode, it
>never
>occured in either UCI or Winboard mode in Linux or MacOS X, and it disappeared
>when
>I compiled without -fbranch-prediction (but this makes the engine much slower).
>
>After spending a few hours debugging, I found that the crash occurs in the
>following
>innocent-looking function:
>
>void uci_wait_for_command() {
>  char command[10000];
>
>  fgets(command, 10000, stdin);
>  uci_handle_command(command); }
>
>It is the call to fgets which causes the crash.  The reason why the problem
>occures at
>move 109 or 110 is probably because the string sent by the GUI with the
>"position"
>command gets very long (though nowhere near 10000 characters)  after so many
>moves.
>
>Increasing the size of the command[] array did not have any effect.  However,
>when I
>changed the command[] array to a global variable, the crashes suddenly
>disappeared.
>
>Is this likely to be a bug in gcc, or could it be caused by a bug somewhere else
>in
>my source code?
>
>Tord

  I don't know GCC, but that looks like the compiler doesn't allocate enough
stack space for that array (because you say a global variable fixes the
problem). Is there somewhere in GCC where you can configure a max stack size?

  José C.



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.