There seems to be a bug in xmame.xgl (from games-emulation/xmame-0.83.1) where it segfaults if -widthscale or -heightscale is set to more than 1. I have compiled xmame with debugging symbols and believe I have tracked down this problem. Further, I also believe this should be reproducible on any machine, regardless of video card (although I have not tested this.) Here is a relevant backtrace from gdb: #0 0xb75bdfe4 in ?? () from /usr/lib/opengl/nvidia/lib/libGL.so.1 #1 0x089f253c in getGLProcAddressHelper (libGLName=0xaa1d398 "libGL.so.1", libGLUName=0x1 <Address 0x1 out of bounds>, func=0x92ccbc1 "glGetString", method=0x0, debug=1, verbose=0) at gltool.c:461 #2 0x089f264d in fetch_GL_FUNCS (libGLName=0xaa1d398 "libGL.so.1", libGLUName=0xaa0f920 "libGLU.so.1", force=1) at gl-disp-fetch.hc:7 #3 0x089f16a7 in sysdep_create_display (depth=16) at xgl.c:302 #4 0x089b1caa in change_display_settings (new_visual=0x1, new_palette=0x10, new_widthscale=2, new_heightscale=2, new_use_aspect_ratio=0, force_new_visual=0) at video.c:656 #5 0x089b1df8 in update_visible_area (display=0x9fc8ca0) at video.c:730 #6 0x089b2413 in osd_update_video_and_audio (display=0x9fc8ca0) at video.c:999 #7 0x080b1bf3 in artwork_update_video_and_audio (display=0x9fc8ca0) at artwork.c:753 #8 0x0804ca95 in update_video_and_audio () at mame.c:1304 #9 0x0809134a in showgamewarnings (bitmap=0xab5d250) at usrintrf.c:2644 #10 0x0804bc14 in run_machine_core () at mame.c:544 #11 0x0804bb91 in run_machine () at mame.c:509 #12 0x0804b8a8 in run_game (game=1) at mame.c:336 #13 0x089af444 in main (argc=1, argv=0x1) at main.c:94 At first glance, it appears like the bug is in the nVidia drivers. However, I have found this not to be the case. The problem is that xmame unloads and reloads the OpenGL libraries, but fails to relocate the disp__glXGetProcAddress variable to the new entrypoint. When the program attempts to call the procedure, it fails, as the entrypoint is not valid. First, some gdb context. Notice the "-widthscale 2 -heightscale 2" arguments in particular, as these are key to the problem: --- ciaran@downstairs ~/oldhome/xmame-src/unix/video-drivers $ gdb /usr/games/bin/xmame.xgl GNU gdb 6.3 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 "i686-pc-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1". (gdb) break change_display_settings Breakpoint 1 at 0x89b1bd8: file video.c, line 624. (gdb) break fetch_GL_FUNCS Breakpoint 2 at 0x89f25da: file gltool.c, line 553. (gdb) set args -rompath /home/ciaran/mame/roms/ -samplepath /usr/lib/games/xmame/samples/ -artwork_directory /usr/lib/games/xmame/artwork -snapshot_directory /usr/lib/games/xmame/snap -hiscore_directory /home/ciaran/.xmame/hi -cheat_file /usr/lib/games/xmame/cheat.dat -hiscore_file /usr/lib/games/xmame/hiscore.dat -history_file /usr/lib/games/xmame/history.dat -mameinfo_file /usr/lib/games/xmame/mameinfo.dat -diff_directory /home/ciaran/.xmame/diff -ctrlr_directory /usr/lib/games/xmame/ctrlr -inipath /home/ciaran/.xmame/ini -nvram_directory /home/ciaran/.xmame/nvram -memcard_directory /home/ciaran/.xmame/memcard -input_directory /home/ciaran/.xmame/inp -state_directory /home/ciaran/.xmame/sta -nofullscreen -bpp 0 -arbheight 0 -heightscale 2 -widthscale 2 -effect 0 -noautodouble -noscanlines -frameskipper 1 -throttle -nosleepidle -autoframeskip -maxautoframeskip 8 -frameskip 0 -brightness 1 -gamma1 -nonorotate -noror -norol -noflipx -noflipy -gldblbuffer -gltexture_size 0 -noglforceblitmode -glext78 -glbilinear -gldrawbitmap -glcolormod -glalphablending -glantialias -gllibname libGL.so.1 -glulibname libGLU.so.1 -nocabview -sound -samples -samplefreq 22050 -bufsize 3 -volume 0 -alsa-pcm default -alsa-buffer 250000 -dsp-plugin oss -sound-mixer-plugin oss -joytype 0 -noanalogstick -nomouse -nousbpspad -norapidfire -nograbmouse -nograbkeyboard -nowinkeys -nougcicoin -artwork -use_backdrops -use_overlays -use_bezels -noartwork_crop -artwork_resolution 0 -cheat -cfg_directory /home/ciaran/.xmame/cfg -noskip_disclaimer -noskip_gameinfo -noloadconfig outrun (gdb) run Starting program: [...insanely long command cut...] --- Now, an excerpt of gdb output from a segfaulted xmame.xgl session (relevant lines highlighted by me with >>>>): --- Breakpoint 1, change_display_settings (new_visual=0xab5d220, new_palette=0x0, new_widthscale=179688016, new_heightscale=0, new_use_aspect_ratio=0, force_new_visual=0) at video.c:624 warning: Source file is more recent than executable. 624 { (gdb) cd video-drivers Working directory /mnt/mdk/home/ciaran/xmame-src/unix/video-drivers. (gdb) cont Continuing. GLmame v0.94 - the_peace_version , by Sven Goethel, http://www.jausoft.com, sgoethel@jausoft.com, based upon GLmame v0.6 driver for xmame, written by Mike Oliphant Breakpoint 2, fetch_GL_FUNCS (libGLName=0xe0 <Address 0xe0 out of bounds>, libGLUName=0x0, force=16) at gltool.c:553 warning: Source file is more recent than executable. 553 { >>>> (gdb) print disp__glXGetProcAddress >>>> $1 = (void *(*)(const GLubyte *)) 0xb75bdfe4 <glXGetProcAddressARB> (gdb) n 556 if(force) (gdb) 558 unloadGLLibrary(); (gdb) 559 _firstRun = 1; (gdb) 562 if(!_firstRun) (gdb) 565 if(!loadGLLibrary (libGLName, libGLUName)) (gdb) GLINFO: loaded OpenGL library libGL.so.1! GLINFO: loaded GLU library libGLU.so.1! warning: Source file is more recent than executable. 7 disp__glGetString = (const GLubyte *(CALLBACK *)( GLenum)) >>>> (gdb) print disp__glXGetProcAddress >>>> $2 = (void *(*)(const GLubyte *)) 0xb75bdfe4 <_nv000803gl+51780> (gdb) cont Continuing. Program received signal SIGSEGV, Segmentation fault. 0xb75bdfe4 in ?? () from /usr/lib/opengl/nvidia/lib/libGL.so.1 --- If, however, I use "set variable disp__glXGetProcAddress = glXGetProcAddressARB" before continuing, it runs perfectly: --- Breakpoint 2, fetch_GL_FUNCS (libGLName=0xe0 <Address 0xe0 out of bounds>, libGLUName=0x0, force=16) at gltool.c:553 warning: Source file is more recent than executable. 553 { (gdb) print disp__glXGetProcAddress $3 = (void *(*)(const GLubyte *)) 0xb75bdfe4 <glXGetProcAddressARB> (gdb) n 556 if(force) (gdb) 558 unloadGLLibrary(); (gdb) 559 _firstRun = 1; (gdb) 562 if(!_firstRun) (gdb) 565 if(!loadGLLibrary (libGLName, libGLUName)) (gdb) GLINFO: loaded OpenGL library libGL.so.1! GLINFO: loaded GLU library libGLU.so.1! warning: Source file is more recent than executable. 7 disp__glGetString = (const GLubyte *(CALLBACK *)( GLenum)) (gdb) print disp__glXGetProcAddress $4 = (void *(*)(const GLubyte *)) 0xb75bdfe4 <_nv000803gl+51780> >>>> (gdb) set variable disp__glXGetProcAddress = glXGetProcAddressARB >>>> (gdb) print disp__glXGetProcAddress >>>> $5 = (void *(*)(const GLubyte *)) 0xb75dbfe4 <glXGetProcAddressARB> (gdb) cont Continuing. GLINFO: glPolygonOffsetEXT (3): not implemented ! Breakpoint 2, fetch_GL_FUNCS (libGLName=0x10 <Address 0x10 out of bounds>, libGLUName=0xbfffddb0 "
There seems to be a bug in xmame.xgl (from games-emulation/xmame-0.83.1) where it segfaults if -widthscale or -heightscale is set to more than 1. I have compiled xmame with debugging symbols and believe I have tracked down this problem. Further, I also believe this should be reproducible on any machine, regardless of video card (although I have not tested this.) Here is a relevant backtrace from gdb: #0 0xb75bdfe4 in ?? () from /usr/lib/opengl/nvidia/lib/libGL.so.1 #1 0x089f253c in getGLProcAddressHelper (libGLName=0xaa1d398 "libGL.so.1", libGLUName=0x1 <Address 0x1 out of bounds>, func=0x92ccbc1 "glGetString", method=0x0, debug=1, verbose=0) at gltool.c:461 #2 0x089f264d in fetch_GL_FUNCS (libGLName=0xaa1d398 "libGL.so.1", libGLUName=0xaa0f920 "libGLU.so.1", force=1) at gl-disp-fetch.hc:7 #3 0x089f16a7 in sysdep_create_display (depth=16) at xgl.c:302 #4 0x089b1caa in change_display_settings (new_visual=0x1, new_palette=0x10, new_widthscale=2, new_heightscale=2, new_use_aspect_ratio=0, force_new_visual=0) at video.c:656 #5 0x089b1df8 in update_visible_area (display=0x9fc8ca0) at video.c:730 #6 0x089b2413 in osd_update_video_and_audio (display=0x9fc8ca0) at video.c:999 #7 0x080b1bf3 in artwork_update_video_and_audio (display=0x9fc8ca0) at artwork.c:753 #8 0x0804ca95 in update_video_and_audio () at mame.c:1304 #9 0x0809134a in showgamewarnings (bitmap=0xab5d250) at usrintrf.c:2644 #10 0x0804bc14 in run_machine_core () at mame.c:544 #11 0x0804bb91 in run_machine () at mame.c:509 #12 0x0804b8a8 in run_game (game=1) at mame.c:336 #13 0x089af444 in main (argc=1, argv=0x1) at main.c:94 At first glance, it appears like the bug is in the nVidia drivers. However, I have found this not to be the case. The problem is that xmame unloads and reloads the OpenGL libraries, but fails to relocate the disp__glXGetProcAddress variable to the new entrypoint. When the program attempts to call the procedure, it fails, as the entrypoint is not valid. First, some gdb context. Notice the "-widthscale 2 -heightscale 2" arguments in particular, as these are key to the problem: --- ciaran@downstairs ~/oldhome/xmame-src/unix/video-drivers $ gdb /usr/games/bin/xmame.xgl GNU gdb 6.3 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 "i686-pc-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1". (gdb) break change_display_settings Breakpoint 1 at 0x89b1bd8: file video.c, line 624. (gdb) break fetch_GL_FUNCS Breakpoint 2 at 0x89f25da: file gltool.c, line 553. (gdb) set args -rompath /home/ciaran/mame/roms/ -samplepath /usr/lib/games/xmame/samples/ -artwork_directory /usr/lib/games/xmame/artwork -snapshot_directory /usr/lib/games/xmame/snap -hiscore_directory /home/ciaran/.xmame/hi -cheat_file /usr/lib/games/xmame/cheat.dat -hiscore_file /usr/lib/games/xmame/hiscore.dat -history_file /usr/lib/games/xmame/history.dat -mameinfo_file /usr/lib/games/xmame/mameinfo.dat -diff_directory /home/ciaran/.xmame/diff -ctrlr_directory /usr/lib/games/xmame/ctrlr -inipath /home/ciaran/.xmame/ini -nvram_directory /home/ciaran/.xmame/nvram -memcard_directory /home/ciaran/.xmame/memcard -input_directory /home/ciaran/.xmame/inp -state_directory /home/ciaran/.xmame/sta -nofullscreen -bpp 0 -arbheight 0 -heightscale 2 -widthscale 2 -effect 0 -noautodouble -noscanlines -frameskipper 1 -throttle -nosleepidle -autoframeskip -maxautoframeskip 8 -frameskip 0 -brightness 1 -gamma1 -nonorotate -noror -norol -noflipx -noflipy -gldblbuffer -gltexture_size 0 -noglforceblitmode -glext78 -glbilinear -gldrawbitmap -glcolormod -glalphablending -glantialias -gllibname libGL.so.1 -glulibname libGLU.so.1 -nocabview -sound -samples -samplefreq 22050 -bufsize 3 -volume 0 -alsa-pcm default -alsa-buffer 250000 -dsp-plugin oss -sound-mixer-plugin oss -joytype 0 -noanalogstick -nomouse -nousbpspad -norapidfire -nograbmouse -nograbkeyboard -nowinkeys -nougcicoin -artwork -use_backdrops -use_overlays -use_bezels -noartwork_crop -artwork_resolution 0 -cheat -cfg_directory /home/ciaran/.xmame/cfg -noskip_disclaimer -noskip_gameinfo -noloadconfig outrun (gdb) run Starting program: [...insanely long command cut...] --- Now, an excerpt of gdb output from a segfaulted xmame.xgl session (relevant lines highlighted by me with >>>>): --- Breakpoint 1, change_display_settings (new_visual=0xab5d220, new_palette=0x0, new_widthscale=179688016, new_heightscale=0, new_use_aspect_ratio=0, force_new_visual=0) at video.c:624 warning: Source file is more recent than executable. 624 { (gdb) cd video-drivers Working directory /mnt/mdk/home/ciaran/xmame-src/unix/video-drivers. (gdb) cont Continuing. GLmame v0.94 - the_peace_version , by Sven Goethel, http://www.jausoft.com, sgoethel@jausoft.com, based upon GLmame v0.6 driver for xmame, written by Mike Oliphant Breakpoint 2, fetch_GL_FUNCS (libGLName=0xe0 <Address 0xe0 out of bounds>, libGLUName=0x0, force=16) at gltool.c:553 warning: Source file is more recent than executable. 553 { >>>> (gdb) print disp__glXGetProcAddress >>>> $1 = (void *(*)(const GLubyte *)) 0xb75bdfe4 <glXGetProcAddressARB> (gdb) n 556 if(force) (gdb) 558 unloadGLLibrary(); (gdb) 559 _firstRun = 1; (gdb) 562 if(!_firstRun) (gdb) 565 if(!loadGLLibrary (libGLName, libGLUName)) (gdb) GLINFO: loaded OpenGL library libGL.so.1! GLINFO: loaded GLU library libGLU.so.1! warning: Source file is more recent than executable. 7 disp__glGetString = (const GLubyte *(CALLBACK *)( GLenum)) >>>> (gdb) print disp__glXGetProcAddress >>>> $2 = (void *(*)(const GLubyte *)) 0xb75bdfe4 <_nv000803gl+51780> (gdb) cont Continuing. Program received signal SIGSEGV, Segmentation fault. 0xb75bdfe4 in ?? () from /usr/lib/opengl/nvidia/lib/libGL.so.1 --- If, however, I use "set variable disp__glXGetProcAddress = glXGetProcAddressARB" before continuing, it runs perfectly: --- Breakpoint 2, fetch_GL_FUNCS (libGLName=0xe0 <Address 0xe0 out of bounds>, libGLUName=0x0, force=16) at gltool.c:553 warning: Source file is more recent than executable. 553 { (gdb) print disp__glXGetProcAddress $3 = (void *(*)(const GLubyte *)) 0xb75bdfe4 <glXGetProcAddressARB> (gdb) n 556 if(force) (gdb) 558 unloadGLLibrary(); (gdb) 559 _firstRun = 1; (gdb) 562 if(!_firstRun) (gdb) 565 if(!loadGLLibrary (libGLName, libGLUName)) (gdb) GLINFO: loaded OpenGL library libGL.so.1! GLINFO: loaded GLU library libGLU.so.1! warning: Source file is more recent than executable. 7 disp__glGetString = (const GLubyte *(CALLBACK *)( GLenum)) (gdb) print disp__glXGetProcAddress $4 = (void *(*)(const GLubyte *)) 0xb75bdfe4 <_nv000803gl+51780> >>>> (gdb) set variable disp__glXGetProcAddress = glXGetProcAddressARB >>>> (gdb) print disp__glXGetProcAddress >>>> $5 = (void *(*)(const GLubyte *)) 0xb75dbfe4 <glXGetProcAddressARB> (gdb) cont Continuing. GLINFO: glPolygonOffsetEXT (3): not implemented ! Breakpoint 2, fetch_GL_FUNCS (libGLName=0x10 <Address 0x10 out of bounds>, libGLUName=0xbfffddb0 "ð\b¶\n\220Ƶ\n\001", force=178301596) at gltool.c:553 553 { (gdb) cont Continuing. GLINFO: OpenGL Driver Information: vendor: NVIDIA Corporation, renderer GeForce4 Ti 4400/AGP/SSE2, version 1.5.2 NVIDIA 66.29 [...other successful startup messages...] --- and xmame works fine. This problem does not occur when -widthscale = 1 and -heightscale = 1, due to the following if construct in change_display_settings() in video.c: --- 637 if (force_new_visual 638 || visual_width != new_visual_width 639 || visual_height != new_visual_height 640 || widthscale != new_widthscale 641 || heightscale != new_heightscale 642 || use_aspect_ratio != new_use_aspect_ratio) 643 { [...] 656 if (sysdep_create_display(new_depth) != OSD_OK) ---- Thus, the display is only recreated if any of the parameters mentioned differ from the default, and thus the bug occurs. At first glance, this seems to be a coding error; the fix should be easy, although I myself don't have enough xmame/GLX coding knowledge to implement it. I should note too, however, that for some reason it only occurs with some games. I have not looked too deeply into why this is so, but I do know that it happens with "outrun", and most other games. It does *not* happen with "centiped", to name one game. In case it turns out to be relevant, I'm using an NVidia GeForce4 Ti4400, using the media-video/nvidia-glx-1.0-6629-r1 drivers. Hopefully I've given enough info for the relevant maintainers to be able to implement a fix! If not, let me know. Reproducible: Always Steps to Reproduce: 1. emerge xmame with USE="opengl". 2. Invoke xmame with "xmame.xgl -widthscale 2 -heightscale 2" followed by a game. Actual Results: xmame.xgl segfaulted, as above. If it doesn't happen for you, try another game. "outrun" seems to exhibit this behaviour. Expected Results: xmame should have run the game. Portage 2.0.51.19 (default-linux/x86/2005.0, gcc-3.3.5-20050130, glibc-2.3.4.20041102-r1, 2.6.9-gentoo-r9 i686) ================================================================= System uname: 2.6.9-gentoo-r9 i686 Intel(R) Pentium(R) 4 CPU 1400MHz Gentoo Base System version 1.4.16 Python: dev-lang/python-2.3.5 [2.3.5 (#1, May 5 2005, 05:45:17)] distcc 2.16 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled] ccache version 2.3 [enabled] dev-lang/python: 2.3.5 sys-apps/sandbox: [Not Present] sys-devel/autoconf: 2.59-r6, 2.13 sys-devel/automake: 1.7.9-r1, 1.8.5-r3, 1.5, 1.4_p6, 1.6.3, 1.9.5 sys-devel/binutils: 2.15.92.0.2-r7 sys-devel/libtool: 1.5.16 virtual/os-headers: 2.6.8.1-r2 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CFLAGS="-O2 -mcpu=i686 -pipe" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.3/env /usr/kde/3.3/share/config /usr/kde/3.3/shutdown /usr/kde/3/share/config /usr/lib/X11/xkb /usr/share/config /var/bind /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="" DISTDIR="/usr/portage/distfiles" FEATURES="autoaddcvs autoconfig ccache distlocks sandbox sfperms strict" GENTOO_MIRRORS="http://gentoo.blueyonder.co.uk/ http://distfiles.gentoo.org/" MAKEOPTS="-j2" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/home/ciaran/portage/overlay" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="x86 X acpi alsa apm avi berkdb bitmap-fonts cdr crypt cups curl dga divx4linux dvd eds emboss encode esd fam flac foomaticdbfortran gd gdbm gif gmail gnome gphoto2 gpm gstreamer gtk gtk2 imagemagick imlib ipv6 jack java jbig joystick jpeg kde kdeenablefinal ladspa libg++ libwww mad mikmod mmx motif mozsvg mp3 mpeg multitarget mysql ncurses nls nodrm nptl ogg oggvorbis opengl oss pam pdflib perl pic png povray ppds python qt quicktime readline real samba sdl slang sse ssl svga tcpd tiff truetype truetype-fonts type1-fonts v4l vorbis xine xml2 xmms xv zlib userland_GNU kernel_linux elibc_glibc" Unset: ASFLAGS, CBUILD, CTARGET, LANG, LC_ALL, LDFLAGS, LINGUAS
Just came across some more info that may be helpful. Examine the two addresses closely: 0xb75dbfe4 <glXGetProcAddressARB> 0xb75bdfe4 <_nv000803gl+51780> Notice how the two addresses are identical *except* for the "b" and "d", which are swapped around. Notice also that they're in different bytes, meaning that this is almost certainly human error. It also means that this problem is perhaps not related to xmame, but is instead a problem with the NVidia drivers. I haven't got enough time to further investigate right now, but I will do later.
give 0.96 a shot.
0.96 doesn't seem to compile an xmame.xgl file, even with USE="opengl", so I can't test it properly. Here's the output of "emerge -pv xmame" with the ~x86 keyword set in /etc/portage/package.keywords: [ebuild R ] games-emulation/xmame-0.96 +X +alsa -arts -debug +dga +esd -expat -ggi +joystick -lirc +mmx +net +opengl +sdl +svga +xv 0 kB [1] Note that although it's in my overlay, I haven't changed the 0.96 ebuild. However, I also haven't emerge sync'd today so I'll do that next time and get rid of (or rename) the overlay version. I won't be doing more testing tonight as I have no time. However, I'll emerge sync and let the compile run overnight, so tomorrow I should be able to get back to you on whether the latest sync works or not. Thanks!
Unfortunately, after resyncing and re-emerging xmame-0.96, I still have no xmame.xgl binary. :( I would try 0.94 or 0.95, but I notice they've disappeared from the Portage tree. I still have their ebuilds in my overlay, though. Should I try them?
The newer xmame versions don't create a xmame.xgl binary. I'm more interested in the issue with the segfault. Does the new version segfault or not?
need feedback.
Whoops, sorry. I thought I had replied, but I guess not. The new version doesn't segfault as far as I can see, but it also seems to want more files in my ROM dumps, so the "outrun" ROMs I have don't work. Other games seem to be more or less okay, though, with no segfaults. Sorry for not trying the masked version first. :D
ok
Sounds fixed to me.