Eschecs FreeBASIC (UCI chess GUI)

User projects written in or related to FreeBASIC.
Post Reply
ur_naz
Posts: 49
Joined: Mar 02, 2016 12:44

Re: Eschecs 1.0 (UCI chess GUI)

Post by ur_naz »

it hangs off on my system =(
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs 1.0 (UCI chess GUI)

Post by Roland Chastain »

ur_naz wrote:it hangs off on my system =(
Thank you for testing. Sorry that the program doesn't work on your system. Could you make a description of what happens?

What I see here from time to time is that while the computer piece is moving, the piece stops and the application crashes. I do not know where it comes from. Is that the problem you found?

Has anyone else tried the program?
VANYA
Posts: 1834
Joined: Oct 24, 2010 15:16
Location: Ярославль
Contact:

Re: Eschecs 1.0 (UCI chess GUI)

Post by VANYA »

Hi Roland!

The program works, but after a few moves hangs. OS: windows XP sp3
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs 1.0 (UCI chess GUI)

Post by Roland Chastain »

Hello VANYA! Thank you.
VANYA wrote:The program works, but after a few moves hangs. OS: windows XP sp3
I found something.
Microsoft Windows [version 10.0.16299.371]
(c) 2017 Microsoft Corporation. Tous droits réservés.

C:\Atelier\Basic\chess\eschecs>build
Deleting eschecs.exe
Current directory: C:\Atelier\Basic\chess\eschecs

C:\Atelier\Basic\chess\eschecs>eschecs

Aborting due to runtime error 12 ("segmentation violation" signal) in C:\Atelier\Basic\chess\eschecs\source\sgui\sGUI_SystemEvents.bas::GETSYSEVENTS()


C:\Atelier\Basic\chess\eschecs>
In build.cmd, I had replaced "%fbc% -s gui -w all" by "%fbc% -s console -exx -w all".

I don't know what to do. My apologies to people who downloaded the program yesterday. Any suggestion welcome.
Last edited by Roland Chastain on Apr 30, 2018 12:54, edited 1 time in total.
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs 1.0 (UCI chess GUI)

Post by Roland Chastain »

I went through the file sGUI_SystemEvents.bas: I did not notice anything particular. This is the part of the library that detects events related to the mouse and keyboard. If anyone had an idea ...

By the way, why the compiler doesn't give the line number where the error occurs?

The application closes when the piece arrives at its destination.
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Eschecs 1.0 (UCI chess GUI)

Post by paul doe »

Roland Chastain wrote:I went through the file sGUI_SystemEvents.bas: I did not notice anything particular. This is the part of the library that detects events related to the mouse and keyboard. If anyone had an idea ...
In another thread I published a link to Dr. Memory, a tool that can be useful in such scenarios.

To use it, compile your program with debug information (if you're using GCC, the command line parameter is -gen gcc -Wc -ggdb), and execute it in Dr. Memory like this:

If you're using a 64-bit system:
drmemory -ignore_kernel -- yourprogram.exe (because it's 32-bit for now, you have to 'fudge' it to work in 64-bit mode)

If not, simply remove the -ignore_kernel parameter and invoke it normally:

drmemory -- yourprogram.exe

Or you can use gdb (included with FB)...
ur_naz
Posts: 49
Joined: Mar 02, 2016 12:44

Re: Eschecs 1.0 (UCI chess GUI)

Post by ur_naz »

Roland Chastain wrote:
ur_naz wrote:it hangs off on my system =(
Thank you for testing. Sorry that the program doesn't work on your system. Could you make a description of what happens?

What I see here from time to time is that while the computer piece is moving, the piece stops and the application crashes. I do not know where it comes from. Is that the problem you found?

Has anyone else tried the program?
it just freezes after some moves and application is not responding (win7 x64)
And even if i close aplication after crash basic.exe (why not eschess.exe?) is still in process explorer
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Eschecs 1.2.1 (UCI chess GUI)

Post by Roland Chastain »

I repaired one bug. Actually it had no relation to sGUI.

Here (Windows 10) the application seems to work. Please test it.

freebasic-eschecs-20180430.zip

@ur_naz
Thank you for report. I also had problems with basic.exe, so it isn't included in the latest release.

@paul doe
Thank you for the link. I downloaded the tool.
ur_naz
Posts: 49
Joined: Mar 02, 2016 12:44

Re: Eschecs 1.2.1 (UCI chess GUI)

Post by ur_naz »

still freezes but less. this version is French? previous was Deutsch... maybe add menu for select language
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs 1.2.1 (UCI chess GUI)

Post by Roland Chastain »

@ur_naz

Thank you for testing the French version. :)

Yes, a language menu is a good idea, but for now I would prefer to understand why the application freezes.

To build the English version, open a command prompt, change directory to Eschecs main directory, and enter "build english". (Before that you will have to modify the compiler path in build.cmd.)
grindstone
Posts: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: Eschecs 1.2.1 (UCI chess GUI)

Post by grindstone »

Eschecs seems to freeze when a piece moves to the lower border of the board (row 1).
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs 1.2.1 (UCI chess GUI)

Post by Roland Chastain »

Found and corrected a bug (which was an unforeseen effect of a previous fix): in case of promotion, the chessboard was not redrawn correctly.

You can download the new files.

But concerning the freezing, I did not advance. In fact, I do not know where to look.

@grindstone

Thank you for your observation but unfortunately I did not find anything.
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs 1.2.1 (UCI chess GUI)

Post by Roland Chastain »

Hello!

It's sad to let this project in such a state, but unfortunately I don't have time to work on it, and furthermore I have no idea why the application freezes. If ever someone would be interested to search the bug and even continue this project alone, he would be welcome.

More than 10000 downloads on FB Portal!

Here is the download page.

Best regards.

Roland
paul doe
Moderator
Posts: 1730
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Eschecs 1.2.1 (UCI chess GUI)

Post by paul doe »

Roland Chastain wrote:Hello!

It's sad to let this project in such a state, but unfortunately I don't have time to work on it, and furthermore I have no idea why the application freezes. If ever someone would be interested to search the bug and even continue this project alone, he would be welcome.
Hi, Roland!

Your problem, basically, lies in the mouse polling that sGUI does. Look at this snippet:

Code: Select all

#include once "fbgfx.bi"

type threadedSub as sub( byval as any ptr )

type Thread
  public:
    declare constructor( _
      byval as threadedSub, _
      byval as any ptr )
      
    declare destructor()
    
    declare sub start()
    declare sub finish()
    
  private:
    declare constructor()
    declare static sub run( _
      byval as Thread ptr )
    
    m_threadID as any ptr
    m_running as boolean
    m_callback as threadedSub
    m_param as any ptr
end type

constructor Thread()
end constructor

constructor Thread( _
  byval aCallback as threadedSub, _
  byval aParameter as any ptr )
  
  m_callback = aCallback
  m_param = aParameter
  
  m_threadID = threadCreate( _
     cptr( sub( byval as any ptr ), @run ), @this )
end constructor

destructor Thread()
  finish()
  threadWait( m_threadID )
end destructor

sub Thread.run( _
  byval anInstance as Thread ptr )
  
  do while( anInstance->m_running )
    anInstance->m_callBack( anInstance->m_param )
    sleep( 1, 1 )
  loop
end sub

sub Thread.start()
  m_running = true 
end sub

sub Thread.finish()
  m_running = false
end sub

type MouseInfo
  x as integer
  y as integer
  button as integer
end type

sub HangingPollMouse( byval info as MouseInfo ptr )
  getMouse( info->x, info->y, , info->button )
end sub

sub PollMouse( byval info as MouseInfo ptr )
  dim as fb.event e
  
  if( screenEvent( @e ) <> 0 ) then
    select case as const e.type
      case fb.EVENT_MOUSE_MOVE
        info->x = e.x
        info->y = e.y
    end select
  end if
end sub

screenRes( 800, 600, 32 )

dim as MouseInfo myInfo

'' This works OK
dim as threadedSub myCallback = _
  cptr( sub( byval as any ptr ), @PollMouse )

'' Try this one instead, it hangs the process
'dim as threadedSub myCallback = _
'  cptr( sub( byval as any ptr ), @HangingPollMouse )
  
var aThread = Thread( myCallback, @myInfo )
aThread.start()

do
  screenLock()
    cls()
    line( myInfo.x - 50, myInfo.y - 50 ) - _
      ( myInfo.x + 50, myInfo.y + 50 ), _
      rgba( 255, 0, 0, 255 ), bf
  screenUnlock()
  
  sleep( 1, 1 )
loop until( inkey() <> "" )

aThread.finish()
In it, you'll see a red rectangle, which you can move with the mouse. The polling of the mouse is done on another thread, which is implemented as a simple class here. However, look at how pollingMouse() is implemented: it uses screenEvent() instead of the more common getMouse() method. The problem is, if you poll the mouse in another thread using getMouse(), the process hangs, which is what happens to your program (since sGUI does the polling using getMouse()). To see this, uncomment the two lines in the above code and see what happens: it works for a while, then the process dies.

The solution is easy but, unfortunately, it requires patching of the sGUI library, but you'll have to untangle it to do so. I hope that this helps you, or at least give you a hint where to look =D
Roland Chastain wrote:More than 10000 downloads on FB Portal!
Congratulations for reaching this milestone! =D
Roland Chastain
Posts: 993
Joined: Nov 24, 2011 19:49
Location: France
Contact:

Re: Eschecs 1.2.1 (UCI chess GUI)

Post by Roland Chastain »

@paul doe

Hi! Thank you for your kind and instructive answer. I know where to look now. :)
Post Reply