XBoard (GtkBoard?) pre-alpha

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
lucasart
Posts: 3232
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: XBoard (GtkBoard?) pre-alpha

Post by lucasart »

how about calling it GBoard, instead of GtkBoard ? It's simpler and cuter :D
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: XBoard (GtkBoard?) pre-alpha

Post by JoshPettus »

ok

Code: Select all

./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether gcc and cc understand -c and -o together... yes
checking how to run the C preprocessor... gcc -E
checking for library containing strerror... none required
checking whether NLS is requested... yes
checking for msgfmt... /sw/bin/msgfmt
checking for gmsgfmt... /sw/bin/msgfmt
checking for xgettext... /sw/bin/xgettext
checking for msgmerge... /sw/bin/msgmerge
checking build system type... x86_64-apple-darwin12.2.0
checking host system type... x86_64-apple-darwin12.2.0
checking for ld used by GCC... /usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld
checking if the linker (/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin11/4.2.1/ld) is GNU ld... no
checking for shared library run path origin... done
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for CFPreferencesCopyAppValue... yes
checking for CFLocaleCopyCurrent... yes
checking for GNU gettext in libc... no
checking for iconv... yes
checking for working iconv... yes
checking how to link with libiconv... -liconv
checking for GNU gettext in libintl... no
checking whether to use NLS... no
checking for remsh... no
checking for rsh... rsh
checking for makeinfo... makeinfo
checking for nroff... nroff -man
checking for awk... /usr/bin/awk
checking for perl... /usr/bin/perl
checking for pkg-config... /sw/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for GTK... yes
checking for ANSI C header files... yes
checking whether time.h and sys/time.h may both be included... yes
checking for sys/wait.h that is POSIX.1 compatible... yes
checking for dirent.h that defines DIR... yes
checking for library containing opendir... none required
checking return type of signal handlers... void
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking stropts.h usability... no
checking stropts.h presence... no
checking for stropts.h... no
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking for string.h... (cached) yes
checking for unistd.h... (cached) yes
checking sys/systeminfo.h usability... no
checking sys/systeminfo.h presence... no
checking for sys/systeminfo.h... no
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking sys/socket.h usability... yes
checking sys/socket.h presence... yes
checking for sys/socket.h... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking for _getpty... no
checking for grantpt... yes
checking for setitimer... yes
checking for usleep... yes
checking for gettimeofday... yes
checking for random... yes
checking for gethostname... yes
checking for setlocale... yes
checking for getpseudotty in -lseq... no
checking whether compiler understands -Wall -Wno-parentheses... yes
checking for X... libraries /usr/X11/lib, headers /usr/X11/include
checking whether -R must be followed by a space... no
checking for gethostbyname... yes
checking for connect... yes
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking X11/Intrinsic.h usability... yes
checking X11/Intrinsic.h presence... yes
checking for X11/Intrinsic.h... yes
checking X11/Xaw/Dialog.h usability... yes
checking X11/Xaw/Dialog.h presence... yes
checking for X11/Xaw/Dialog.h... yes
checking for CAIRO... yes
checking X11/xpm.h usability... yes
checking X11/xpm.h presence... yes
checking for X11/xpm.h... yes
checking for XpmReadFileToPixmap in -lXpm... yes
checking whether ptys or pipes should be used... pipes
checking for xdg-mime... no
checking for xdg-desktop-menu... no
checking for xdg-icon-resource... no
configure: creating ./config.status
config.status: creating Makefile
config.status: creating cmail
config.status: creating po/Makefile.in
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing po-directories commands
config.status: creating po/POTFILES
config.status: creating po/Makefile
config.status: executing test-stamp-h commands
config.status: executing chmod-cmail commands

 Configurations summary:

        prefix:          /usr/local       
        datarootdir:     ${prefix}/share  
        datadir:         ${datarootdir}   (icons will go in $datadir/icons/hicolor/...)
                                    (bitmaps will go in $datadir/games/xboard/...)
        infodir:         ${datarootdir}/info   (info files will go here)
        sysconfdir:      ${prefix}/etc   (xboard.conf will go here)

        update mimedb:   yes

        NLS support:     no

        Xaw3d:           no

        xpm:             yes
        ptys:            pipes
        zippy:           yes
        sigint:          yes
yeilds

Code: Select all

make
make  all-recursive
Making all in po
Updating ./version.texi
restore=: && backupdir=".am$$" && \
	am__cwd=`pwd` && CDPATH="${ZSH_VERSION+.}:" && cd . && \
	rm -rf $backupdir && mkdir $backupdir && \
	if (/bin/sh /Users/herecomethej/Downloads/xboard-52a5f6f/missing --run makeinfo --version) >/dev/null 2>&1; then \
	  for f in xboard.info xboard.info-[0-9] xboard.info-[0-9][0-9] xboard.i[0-9] xboard.i[0-9][0-9]; do \
	    if test -f $f; then mv $f $backupdir; restore=mv; else :; fi; \
	  done; \
	else :; fi && \
	cd "$am__cwd"; \
	if /bin/sh /Users/herecomethej/Downloads/xboard-52a5f6f/missing --run makeinfo   -I . \
	 -o xboard.info xboard.texi; \
	then \
	  rc=0; \
	  CDPATH="${ZSH_VERSION+.}:" && cd .; \
	else \
	  rc=$?; \
	  CDPATH="${ZSH_VERSION+.}:" && cd . && \
	  $restore $backupdir/* `echo "./xboard.info" | sed 's|[^/]*$||'`; \
	fi; \
	rm -rf $backupdir; exit $rc
  CC     backend.o
  CC     book.o
  CC     childio.o
  CC     gamelist.o
  CC     ngamelist.o
  CC     lists.o
  CC     moves.o
  CC     parser.o
  CC     pgntags.o
  CC     uci.o
  CC     xtimer.o
  CC     xboard.o
xboard.c: In function ‘main’:
xboard.c:1040: warning: unused variable ‘gtkerror’
xboard.c: In function ‘FindFont’:
xboard.c:1573: warning: unused variable ‘pxlSize’
xboard.c:1573: warning: unused variable ‘err’
xboard.c:1573: warning: unused variable ‘minerr’
xboard.c:1573: warning: unused variable ‘nfonts’
xboard.c:1573: warning: unused variable ‘j’
xboard.c:1573: warning: unused variable ‘i’
xboard.c:1572: warning: unused variable ‘scalableTail’
xboard.c:1572: warning: unused variable ‘scalable’
xboard.c:1572: warning: unused variable ‘best’
xboard.c:1572: warning: unused variable ‘fonts’
xboard.c: In function ‘KeyPressProc’:
xboard.c:1661: warning: implicit declaration of function ‘MoveTypeInProc’
xboard.c: At top level:
xboard.c:2102: warning: conflicting types for ‘MoveTypeInProc’
xboard.c:1661: warning: previous implicit declaration of ‘MoveTypeInProc’ was here
bitmaps/icon_white.bm:3: warning: ‘icon_white_bits’ defined but not used
bitmaps/icon_black.bm:3: warning: ‘icon_black_bits’ defined but not used
bitmaps/checkmark.bm:4: warning: ‘checkmark_bits’ defined but not used
xboard.c:1715: warning: ‘do_flash_delay’ defined but not used
xboard.c:1736: warning: ‘wpNew’ defined but not used
xboard.c:2191: warning: ‘NullXErrorCheck’ defined but not used
  CC     menus.o
  CC     draw.o
  CC     usounds.o
  CC     usystem.o
  CC     board.o
board.c: In function ‘DrawPosition’:
board.c:918: warning: implicit declaration of function ‘MarkMenuItem’
  CC     engineoutput.o
  CC     nengineoutput.o
nengineoutput.c:72: warning: ‘currentPV’ defined but not used
  CC     xengineoutput.o
pixmaps/WHITE_14.xpm:2: warning: ‘WHITE_14’ defined but not used
pixmaps/BLACK_14.xpm:2: warning: ‘BLACK_14’ defined but not used
pixmaps/CLEAR_14.xpm:2: warning: ‘CLEAR_14’ defined but not used
pixmaps/UNKNOWN_14.xpm:2: warning: ‘UNKNOWN_14’ defined but not used
pixmaps/THINKING_14.xpm:2: warning: ‘THINK_14’ defined but not used
pixmaps/PONDER_14.xpm:2: warning: ‘PONDER_14’ defined but not used
pixmaps/ANALYZING_14.xpm:2: warning: ‘ANALYZE_14’ defined but not used
xengineoutput.c:81: warning: ‘currentPV’ defined but not used
xengineoutput.c:86: warning: ‘memoWidget’ defined but not used
  CC     evalgraph.o
  CC     nevalgraph.o
  CC     xgamelist.o
  CC     history.o
  CC     nhistory.o
nhistory.c: In function ‘SelectMove’:
nhistory.c:77: warning: implicit declaration of function ‘FindMoveByCharIndex’
  CC     xhistory.o
  CC     xoptions.o
xoptions.c: In function ‘GetWidgetTextGTK’:
xoptions.c:154: warning: assignment discards qualifiers from pointer target type
xoptions.c: In function ‘HighlightItem’:
xoptions.c:305: warning: passing argument 1 of ‘gtk_tree_view_scroll_to_cell’ from incompatible pointer type
xoptions.c:303: warning: unused variable ‘iter’
xoptions.c:301: warning: unused variable ‘store’
xoptions.c:297: warning: unused variable ‘data’
xoptions.c:297: warning: unused variable ‘value’
xoptions.c: In function ‘CreateMenuPopup’:
xoptions.c:424: warning: passing argument 1 of ‘gtk_check_menu_item_set_draw_as_radio’ from incompatible pointer type
xoptions.c:427: warning: cast to pointer from integer of different size
xoptions.c: In function ‘GameListEvent’:
xoptions.c:512: warning: cast from pointer to integer of different size
xoptions.c: In function ‘MemoEvent’:
xoptions.c:572: warning: passing argument 1 of ‘gtk_text_view_window_to_buffer_coords’ from incompatible pointer type
xoptions.c:573: warning: passing argument 1 of ‘gtk_text_view_get_iter_at_location’ from incompatible pointer type
xoptions.c:545: warning: unused variable ‘opt’
xoptions.c: In function ‘AddHandler’:
xoptions.c:607: warning: cast to pointer from integer of different size
xoptions.c: In function ‘GraphEventProc’:
xoptions.c:780: warning: unused variable ‘sizing’
xoptions.c:780: warning: unused variable ‘j’
xoptions.c: In function ‘GenericPopUp’:
xoptions.c:1104: warning: passing argument 2 of ‘gtk_dialog_new_with_buttons’ from incompatible pointer type
xoptions.c: At top level:
xoptions.c:954: warning: ‘oneLiner’ defined but not used
xoptions.c:957: warning: ‘scrollTranslations’ defined but not used
xoptions.c:964: warning: ‘SqueezeIntoBox’ defined but not used
  CC     dialogs.o
dialogs.c:935: warning: initialization from incompatible pointer type
dialogs.c: In function ‘PopUpMoveDialog’:
dialogs.c:1214: warning: implicit declaration of function ‘CursorAtEnd’
dialogs.c: In function ‘FileNamePopUp’:
dialogs.c:2559: warning: implicit declaration of function ‘FileNamePopUpGTK’
  CC     zippy.o
  CCLD   xboard
./texi2man ./xboard.texi > xboard.man || (rm -f xboard.man ; false)
  GEN    xboard.conf
I tried a make install as well to make sure everything was where xboard would have wanted it to be. but still seg 11. It's possible it is still related to my issue with svg files with the other branch.

Why did he not want to include them? Perhaps its my apple way of thinking, but things included in the application in order to improve ease of use and avoid setup issues can only be a good thing. :) If he wants to be able to supply other svg files then surly you can redirect xboard to the somewhere else.
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: XBoard (GtkBoard?) pre-alpha

Post by hgm »

Yes, I am pretty sure the two things are related. The other branch did have built-in old-style pixmaps, and fell back on them when no svg pieces were found in the user-specified -pgnDirectory and -svgDirectory. This version, however, only allows specification of a -pieceImageDirectory, looking for both png and svg pieces in it, and if none of these are found, searches in the hard-coded director where the svg pieces are installed. There is no fallback on built-ins.

It seems somehow that the reading of svg pieces is defective on your system, even when the files are there. In this version, not having any pieces is fatal, and gives the segfault.

I had expected the svg handle returned from rsvg_handle_new_from_file to be NULL if the file could not be successfully loaded. In that case the existing code should finally end up with an error popup (DisplayError). It could be that this still happens, but that the segfault happens so soon after the error popup that it is destroyed before it became visible. I guess I should have printed the error to the console. In any case it would be useful to add a printf to print the svg handle on the console after rsvg_handle_new_from_file.

It should still be possible to run with PNG pieces if you started XBoard with the option -pieceImageDirectory speciifying a directory with PNG pieces.
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: XBoard (GtkBoard?) pre-alpha

Post by JoshPettus »

I put -pieceImageDirectory in the master conf pointing to a png folder and I'm afraid it still failed with seg 11. Is there a command i can use to really see what's going on?

On a side note I'm curious if the svg images were built in if it would still fail. My guess is probably.
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: XBoard (GtkBoard?) pre-alpha

Post by JoshPettus »

Following Jonas's lead on the other thread for a debuger, i come up with this.

Code: Select all

Joshuas-MacBook-Pro:xboard-52a5f6f herecomethej$ gdb ./xboard
GNU gdb 6.3.50-20050815 (Apple version gdb-1822) (Sun Aug  5 03:00:42 UTC 2012)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin"...Reading symbols for shared libra(gdb) run   
Starting program: /Users/herecomethej/Downloads/xboard-52a5f6f/xboard 

(xboard:5445): Gtk-CRITICAL **: GdkScreen *gtk_window_get_screen(GtkWindow *): assertion `GTK_IS_WINDOW (window)' failed

(xboard:5445): Gdk-CRITICAL **: gint gdk_screen_get_width(GdkScreen *): assertion `GDK_IS_SCREEN (screen)' failed

(xboard:5445): Gdk-CRITICAL **: gint gdk_screen_get_height(GdkScreen *): assertion `GDK_IS_SCREEN (screen)' failed
GenericPopUp: unexpected case in switch. i=25 type=9 name=menuW.
GenericPopUp: unexpected case in switch. i=26 type=9 name=menuB.
GenericPopUp: unexpected case in switch. i=27 type=9 name=menuD.
Reading symbols for shared libraries . done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000048
0x0000000100afc91e in cairo_set_source_surface ()
(gdb) 
Figures cairo would be the culprit but what can i do about that?
Michel
Posts: 2272
Joined: Mon Sep 29, 2008 1:50 am

Re: XBoard (GtkBoard?) pre-alpha

Post by Michel »

Is there a command i can use to really see what's going on?
Yes. Two commands actually.

(1) valgrind (trivial to use and recommended)
(2) gdb (harder to use; after the crash do bt to get a backtrace).

EDIT: don't forget to recompile with optimization turned off (CFLAGS=-g).
Optimization sometimes obscure the stacktrace a bit (e.g. some functions
are inlined and hence invisible on the stack).
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: XBoard (GtkBoard?) pre-alpha

Post by hgm »

I think there is no need to use extensive debugging tools here. The crash is in cairo, but it happens because cairo got passed an invalid pointer in cairo_source_surface. So cairo is not to blame. The error occurs where the SVG fails to load, and leaves an invalid pointer to the piece it was supposed to load.

You can add the following 3 fprintf statements in the LoadSVG routine in draw.c to get more info. These print to the debug file (xboard.debug), so you would have to run with the option -debug . (NB, replace the whole routine, because I changed also some details about declaring and handling the svgerror variable.)

Code: Select all

RsvgHandle *
LoadSVG (char *dir, int color, int piece)
{
    char buf[MSG_SIZ];
  RsvgHandle *svg=svgPieces[color][piece];
  RsvgDimensionData svg_dimensions;
  GError *svgerror=NULL;
  cairo_surface_t *img;
  cairo_t *cr;

    snprintf(buf, MSG_SIZ, "%s/%s%s.svg", dir, color ? "Black" : "White", pngPieceNames[piece]);

fprintf(debugFP, "load SVG %s\n", buf);
    if(svg || *dir && (svg = rsvg_handle_new_from_file(buf, &svgerror))) {
fprintf(debugFP, "svg handle set to %x\n", svg);
      rsvg_handle_get_dimensions(svg, &svg_dimensions);
      img = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, squareSize,  squareSize);

      cr = cairo_create(img);
      cairo_scale(cr, squareSize/(double) svg_dimensions.width, squareSize/(double) svg_dimensions.height);
      rsvg_handle_render_cairo(svg, cr);
      if(cairo_surface_status(img) == CAIRO_STATUS_SUCCESS) {
        if(pngPieceImages[color][piece]) cairo_surface_destroy(pngPieceImages[color][piece]);
        pngPieceImages[color][piece] = img;
      }
      cairo_destroy(cr);

      return svg;
    }
if(svgerror) fprintf(debugFP, "svgerror = %s\n", svgerror->message);
    return NULL;
}
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: XBoard (GtkBoard?) pre-alpha

Post by JoshPettus »

Thank-you all. I'm learning so much doing this. :) In anycase, I replaced the routine in draw.c, ran debug, and got this:

Code: Select all

recognized 'normal' (-1) as variant normal
recognized 'normal' (-1) as variant normal
recognized 'normal' (-1) as variant normal
shuffleOpenings = 0
load SVG /WhitePawn.svg
load SVG /usr/local/share/games/xboard/themes/default/WhitePawn.svg
svg handle set to f98d5dc0
load SVG /BlackPawn.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackPawn.svg
svg handle set to f98d5e60
load SVG /WhiteKnight.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteKnight.svg
svg handle set to f98d5f00
load SVG /BlackKnight.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackKnight.svg
svg handle set to f98d7840
load SVG /WhiteBishop.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteBishop.svg
svg handle set to f98d78e0
load SVG /BlackBishop.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackBishop.svg
svg handle set to f98d7980
load SVG /WhiteRook.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteRook.svg
svg handle set to f98d7a20
load SVG /BlackRook.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackRook.svg
svg handle set to f98d7ac0
load SVG /WhiteQueen.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteQueen.svg
svg handle set to f98d7b60
load SVG /BlackQueen.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackQueen.svg
svg handle set to f98d7c00
load SVG /WhiteAdvisor.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteAdvisor.svg
svg handle set to f98d7ca0
load SVG /BlackAdvisor.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackAdvisor.svg
svg handle set to f98d7d40
load SVG /WhiteElephant.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteElephant.svg
svg handle set to f98d7de0
load SVG /BlackElephant.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackElephant.svg
svg handle set to f98d7e80
load SVG /WhiteArchbishop.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteArchbishop.svg
svg handle set to f98d7f20
load SVG /BlackArchbishop.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackArchbishop.svg
svg handle set to fa023840
load SVG /WhiteMarshall.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteMarshall.svg
svg handle set to fa0238e0
load SVG /BlackMarshall.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackMarshall.svg
svg handle set to fa023980
load SVG /WhiteGold.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteGold.svg
svg handle set to fa023a20
load SVG /BlackGold.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackGold.svg
svg handle set to fa023ac0
load SVG /WhiteCommoner.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteCommoner.svg
svg handle set to fa023b60
load SVG /BlackCommoner.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackCommoner.svg
svg handle set to fa023c00
load SVG /WhiteCanon.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteCanon.svg
svg handle set to fa023ca0
load SVG /BlackCanon.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackCanon.svg
svg handle set to fa023d40
load SVG /WhiteNightrider.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteNightrider.svg
svg handle set to fa023de0
load SVG /BlackNightrider.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackNightrider.svg
svg handle set to fa023e80
load SVG /WhiteCrownedBishop.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteCrownedBishop.svg
svg handle set to fa023f20
load SVG /BlackCrownedBishop.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackCrownedBishop.svg
svg handle set to fa031800
load SVG /WhiteCrownedRook.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteCrownedRook.svg
svg handle set to fa0318a0
load SVG /BlackCrownedRook.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackCrownedRook.svg
svg handle set to fa031940
load SVG /WhitePrincess.svg
load SVG /usr/local/share/games/xboard/themes/default/WhitePrincess.svg
svg handle set to fa0319e0
load SVG /BlackPrincess.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackPrincess.svg
svg handle set to fa031a80
load SVG /WhiteChancellor.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteChancellor.svg
svg handle set to fa031b20
load SVG /BlackChancellor.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackChancellor.svg
svg handle set to fa031bc0
load SVG /WhiteHawk.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteHawk.svg
svg handle set to fa031c60
load SVG /BlackHawk.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackHawk.svg
svg handle set to fa031d00
load SVG /WhiteLance.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteLance.svg
svg handle set to fa031da0
load SVG /BlackLance.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackLance.svg
svg handle set to fa031e40
load SVG /WhiteCobra.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteCobra.svg
svg handle set to fa031ee0
load SVG /BlackCobra.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackCobra.svg
svg handle set to fa04d000
load SVG /WhiteUnicorn.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteUnicorn.svg
svg handle set to fa04d0a0
load SVG /BlackUnicorn.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackUnicorn.svg
svg handle set to fa04d140
load SVG /WhiteKing.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteKing.svg
svg handle set to fa04d1e0
load SVG /BlackKing.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackKing.svg
svg handle set to fa04d280
load SVG /WhiteGoldKnight.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteGoldKnight.svg
svg handle set to fa04d320
load SVG /BlackGoldKnight.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackGoldKnight.svg
svg handle set to fa04d3c0
load SVG /WhiteGoldLance.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteGoldLance.svg
svg handle set to fa04d460
load SVG /BlackGoldLance.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackGoldLance.svg
svg handle set to fa04d500
load SVG /WhiteGoldPawn.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteGoldPawn.svg
svg handle set to fa04d5a0
load SVG /BlackGoldPawn.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackGoldPawn.svg
svg handle set to fa04d640
load SVG /WhiteGoldSilver.svg
load SVG /usr/local/share/games/xboard/themes/default/WhiteGoldSilver.svg
svg handle set to fa04d6e0
load SVG /BlackGoldSilver.svg
load SVG /usr/local/share/games/xboard/themes/default/BlackGoldSilver.svg
svg handle set to fa063030
xboard master-20120930 + fairymax
Reset(1, 0) from gameMode 0
recognized 'normal' (-1) as variant normal
GameEnds(0, (null), 2)
shuffleOpenings = 0
For jokes, i did the bt command to see if there were anything else that might help (valgrind isn't installed on my system). I got this. looks like the cairo crash just causes others to fail. Am i right?

Code: Select all

(gdb) bt
#0  0x0000000100afc91e in cairo_set_source_surface ()
#1  0x000000010008451e in GraphEventProc ()
#2  0x00000001000846e8 in GraphExpose ()
#3  0x000000010007c905 in DrawPosition ()
#4  0x000000010001c26d in InitPosition ()
#5  0x000000010003502f in Reset ()
#6  0x00000001000044b2 in InitBackEnd2 ()
#7  0x000000010006fb3c in main ()
(gdb) 
User avatar
hgm
Posts: 27808
Joined: Fri Mar 10, 2006 10:06 am
Location: Amsterdam
Full name: H G Muller

Re: XBoard (GtkBoard?) pre-alpha

Post by hgm »

Hmm, it seems that this is a different error than Michel's, after all. The SVG files seem to be read without problem: the returned pointers are all non-null, and have plausible values.

The stack trace, however, shows that the failing cairo_set_source_surface was invoked by GraphEventProc, which is the routine that is responsible for the eventual drawing of anything, by copying the drawing from the internal memory buffer to the graphics window.

Code: Select all

static void
GraphEventProc(GtkWidget *widget, GdkEvent *event, gpointer gdata)
{   // handle expose and mouse events on Graph widget
    int w, h;
    int j, button=10, f=1, sizing=0;
    Option *opt, *graph = (Option *) gdata;
    PointerCallback *userHandler = graph->target;
    GdkEventExpose *eevent = (GdkEventExpose *) event;
    GdkEventButton *bevent = (GdkEventButton *) event;
    GdkEventMotion *mevent = (GdkEventMotion *) event;
    cairo_t *cr;

//    if (!XtIsRealized(widget)) return;

    switch(event->type) {
	case GDK_EXPOSE: // make handling of expose events generic, just copying from memory buffer (->choice) to display (->textValue)
	    /* Get window size */
#ifdef TODO_GTK
	    j = 0;
	    XtSetArg(args[j], XtNwidth, &w); j++;
	    XtSetArg(args[j], XtNheight, &h); j++;
	    XtGetValues(widget, args, j);
	    sizing = ((w != graph->max || h != graph->value) && ((XExposeEvent*)event)->count >= 0);
	    graph->max = w; graph->value = h;
	    if(sizing && ((XExposeEvent*)event)->count > 0) { graph->max = 0; return; } // don't bother if further exposure is pending during resize
	    if(!graph->textValue || sizing) { // create surfaces of new size for display widget
		if(graph->textValue) cairo_surface_destroy((cairo_surface_t *)graph->textValue);
		graph->textValue = (char*) cairo_xlib_surface_create(xDisplay, XtWindow(widget), DefaultVisual(xDisplay, 0), w, h);
	    }
	    if(sizing) { // the memory buffer was already created in GenericPopup(),
			 // to give drawing routines opportunity to use it befor first expose event
			 // (which are only processed when main gets to the event loop, so after all init!)
			 // so only change when size is no longer good
		if(graph->choice) cairo_surface_destroy((cairo_surface_t *) graph->choice);
		graph->choice = (char**) cairo_image_surface_create (CAIRO_FORMAT_ARGB32, w, h);
		break;
	    }
#endif
	    cr = gdk_cairo_create(((GtkWidget *) (graph->handle))->window);
fprintf(debugFP, "expose: source=%x, dest=%x, context =%x\n", graph->choice, graph->handle, cr);
	    cairo_set_source_surface&#40;cr, &#40;cairo_surface_t *) graph->choice, 0, 0&#41;;  // <---------- This must be the offending call
	    cairo_set_antialias&#40;cr, CAIRO_ANTIALIAS_NONE&#41;;
	    cairo_rectangle&#40;cr, eevent->area.x, eevent->area.y, eevent->area.width, eevent->area.height&#41;;
	    cairo_fill&#40;cr&#41;;
	    cairo_destroy&#40;cr&#41;;
	default&#58;
	    return;
	case GDK_MOTION_NOTIFY&#58;
	    f = 0;
	    w = mevent->x; h = mevent->y;
	    break;
	case GDK_BUTTON_RELEASE&#58;
	    f = -1; // release indicated by negative button numbers
	case GDK_BUTTON_PRESS&#58;
	    w = bevent->x; h = bevent->y;
	    button = bevent->button;
	    shiftState = bevent->state & GDK_SHIFT_MASK;
	    controlState = bevent->state & GDK_CONTROL_MASK;
    &#125;
    button *= f;

    opt = userHandler&#40;button, w, h&#41;;
#ifdef TODO_GTK
    if&#40;opt&#41; &#123; // user callback specifies a context menu; pop it up
	XUngrabPointer&#40;xDisplay, CurrentTime&#41;;
	XtCallActionProc&#40;widget, "XawPositionSimpleMenu", event, &&#40;opt->name&#41;, 1&#41;;
	XtPopupSpringLoaded&#40;opt->handle&#41;;
    &#125;
    XSync&#40;xDisplay, False&#41;;
#endif
&#125;
There is only one call to cairo_set_surface_create in that routine. It could crash because it is handed a NULL pointer for cr. In that case, it would be the (non-fatal) fault of the preceding gdk_cairo_create, which did supply the cr.

Perhaps you could insert the fprintf I indicated above, so it will print in the debug file what exactly the situation is at this point.
JoshPettus
Posts: 730
Joined: Fri Oct 19, 2012 2:23 am

Re: XBoard (GtkBoard?) pre-alpha

Post by JoshPettus »

i put that code into xoptions.c
during the make process i got this under GraphEventProc'

Code: Select all

xoptions.c&#58; In function ‘GraphEventProc’&#58;
xoptions.c&#58;815&#58; warning&#58; format ‘%x’ expects type ‘unsigned int’, but argument 3 has type ‘char **’
xoptions.c&#58;815&#58; warning&#58; format ‘%x’ expects type ‘unsigned int’, but argument 4 has type ‘void *’
xoptions.c&#58;815&#58; warning&#58; format ‘%x’ expects type ‘unsigned int’, but argument 5 has type ‘struct cairo_t *’
xoptions.c&#58;815&#58; warning&#58; format ‘%x’ expects type ‘unsigned int’, but argument 3 has type ‘char **’
xoptions.c&#58;815&#58; warning&#58; format ‘%x’ expects type ‘unsigned int’, but argument 4 has type ‘void *’
xoptions.c&#58;815&#58; warning&#58; format ‘%x’ expects type ‘unsigned int’, but argument 5 has type ‘struct cairo_t *’
xoptions.c&#58;780&#58; warning&#58; unused variable ‘sizing’
xoptions.c&#58;780&#58; warning&#58; unused variable ‘j’
but it compiled

And this is the what the debug file put out.

Code: Select all

recognized 'normal' (-1&#41; as variant normal
recognized 'normal' (-1&#41; as variant normal
recognized 'normal' (-1&#41; as variant normal
shuffleOpenings = 0
xboard master-20120930 + fairymax
Reset&#40;1, 0&#41; from gameMode 0
recognized 'normal' (-1&#41; as variant normal
GameEnds&#40;0, &#40;null&#41;, 2&#41;
shuffleOpenings = 0
expose&#58; source=eb4483f0, dest=eb867100, context =ecac5590
I take it the expose line was the one generated.