Segmentation Fault in Linux

If you're having problems with Snes9x, or think you've found a bug, this is the place to be.
mangamuscle
Snes9x White Belt
Posts: 13
Joined: Tue Feb 16, 2010 3:38 am

Segmentation Fault in Linux

Post by mangamuscle »

I wonder if the latest version of snes9x-gtk requires OpenGL 2 since every time I choose OpenGL for hardware aceleration I get no graphics on screen (audio plays just fine) and if I activate either "alllow non power of two textures" and/or "use pixel buffer objects" the window closes with only a "segmentation fault" as error message.

I compiled my own binary without any problems.

My OpenGL version is 1.5 (works ok with Google Earth and Stella) and I am using Puppy Linux 4.1.2 w/GCC 4.2.2 on a one Ghz (fsb 133) pIII with an nvidia vanta card (using the latest nvidia drivers released for it).

Edit: I forgot to mention I am using SDL 1.2.14
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

Could you post the output of your "glxinfo" command?
mangamuscle
Snes9x White Belt
Posts: 13
Joined: Tue Feb 16, 2010 3:38 am

Post by mangamuscle »

BearOso wrote:Could you post the output of your "glxinfo" command?
Here it is:

Code: Select all

name of display: :0.0
display: :0  screen: 0
direct rendering: Yes
server glx vendor string: NVIDIA Corporation
server glx version string: 1.3
server glx extensions:
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_SGIX_fbconfig, 
    GLX_SGIX_pbuffer, GLX_SGI_video_sync, GLX_SGI_swap_control
client glx vendor string: NVIDIA Corporation
client glx version string: 1.3
client glx extensions:
    GLX_ARB_get_proc_address, GLX_ARB_multisample, GLX_EXT_visual_info, 
    GLX_EXT_visual_rating, GLX_EXT_import_context, GLX_SGI_video_sync, 
    GLX_NV_swap_group, GLX_NV_video_out, GLX_SGIX_fbconfig, GLX_SGIX_pbuffer, 
    GLX_SGI_swap_control, GLX_NV_float_buffer
GLX version: 1.3
GLX extensions:
    GLX_EXT_visual_info, GLX_EXT_visual_rating, GLX_SGIX_fbconfig, 
    GLX_SGIX_pbuffer, GLX_SGI_video_sync, GLX_SGI_swap_control, 
    GLX_ARB_get_proc_address
OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: RIVA TNT2/AGP/SSE
OpenGL version string: 1.5.3 NVIDIA 71.86.06
OpenGL extensions:
    GL_ARB_imaging, GL_ARB_multitexture, GL_ARB_point_parameters, 
    GL_ARB_texture_env_add, GL_ARB_texture_mirrored_repeat, 
    GL_ARB_transpose_matrix, GL_ARB_vertex_buffer_object, GL_ARB_window_pos, 
    GL_EXT_texture_env_add, GL_EXT_abgr, GL_EXT_bgra, 
    GL_EXT_compiled_vertex_array, GL_EXT_draw_range_elements, 
    GL_EXT_fog_coord, GL_EXT_multi_draw_arrays, GL_EXT_packed_pixels, 
    GL_EXT_pixel_buffer_object, GL_EXT_point_parameters, 
    GL_EXT_rescale_normal, GL_EXT_secondary_color, 
    GL_EXT_separate_specular_color, GL_EXT_stencil_wrap, 
    GL_EXT_texture_edge_clamp, GL_EXT_texture_env_combine, 
    GL_EXT_texture_lod_bias, GL_EXT_texture_object, GL_EXT_vertex_array, 
    GL_IBM_rasterpos_clip, GL_IBM_texture_mirrored_repeat, 
    GL_KTX_buffer_region, GL_NV_blend_square, GL_NV_fog_distance, 
    GL_NV_light_max_exponent, GL_NV_packed_depth_stencil, 
    GL_NV_texgen_reflection, GL_NV_texture_env_combine4, GL_SGIS_multitexture, 
    GL_SUN_slice_accum

   visual  x  bf lv rg d st colorbuffer ax dp st accumbuffer  ms  cav
 id dep cl sp sz l  ci b ro  r  g  b  a bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------
0x21 16 tc  0 16  0 r  y  .  5  6  5  0  4 16  0 16 16 16 16  0 0 None
0x22 16 dc  0 16  0 r  y  .  5  6  5  0  4 16  0 16 16 16 16  0 0 None
0x23 16 tc  0 16  0 r  .  .  5  6  5  0  4 16  0 16 16 16 16  0 0 None
0x24 16 tc  0 16  0 r  y  .  5  6  5  0  4  0  0 16 16 16 16  0 0 None
0x25 16 tc  0 16  0 r  .  .  5  6  5  0  4  0  0 16 16 16 16  0 0 None
0x26 16 dc  0 16  0 r  .  .  5  6  5  0  4 16  0 16 16 16 16  0 0 None
0x27 16 dc  0 16  0 r  y  .  5  6  5  0  4  0  0 16 16 16 16  0 0 None
0x28 16 dc  0 16  0 r  .  .  5  6  5  0  4  0  0 16 16 16 16  0 0 None
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

mangamuscle wrote:

Code: Select all

   visual  x  bf lv rg d st colorbuffer ax dp st accumbuffer  ms  cav
 id dep cl sp sz l  ci b ro  r  g  b  a bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------
0x21 16 tc  0 16  0 r  y  .  5  6  5  0  4 16  0 16 16 16 16  0 0 None
0x22 16 dc  0 16  0 r  y  .  5  6  5  0  4 16  0 16 16 16 16  0 0 None
0x23 16 tc  0 16  0 r  .  .  5  6  5  0  4 16  0 16 16 16 16  0 0 None
0x24 16 tc  0 16  0 r  y  .  5  6  5  0  4  0  0 16 16 16 16  0 0 None
0x25 16 tc  0 16  0 r  .  .  5  6  5  0  4  0  0 16 16 16 16  0 0 None
0x26 16 dc  0 16  0 r  .  .  5  6  5  0  4 16  0 16 16 16 16  0 0 None
0x27 16 dc  0 16  0 r  y  .  5  6  5  0  4  0  0 16 16 16 16  0 0 None
0x28 16 dc  0 16  0 r  .  .  5  6  5  0  4  0  0 16 16 16 16  0 0 None
Is this all the visuals you're getting, or did you truncate the list? There are no 24/32 bit visuals here, and that will certainly cause problems with reuse of the GDK window.
mangamuscle
Snes9x White Belt
Posts: 13
Joined: Tue Feb 16, 2010 3:38 am

Post by mangamuscle »

BearOso wrote:Is this all the visuals you're getting, or did you truncate the list? There are no 24/32 bit visuals here, and that will certainly cause problems with reuse of the GDK window.
Yeah, that is the complete list. ATM I need to use a 16-bit resolution screen mode since I am using a TV (full HD) as a monitor and I thought 16 bit was enough for snes since it had a 15 bit color palette.

Edit: I tried to use fullscreen mode to no avail, it seems it does not change the bit depth to 24 or 32 bits.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

Unfortunately, changing the display depth probably won't make a difference unless the nvidia drivers limit the available GLX visuals to that. GDK always creates a truecolor (24/32 bit) visual, and the OpenGL code in the program reuses the window GDK creates for its display. What might be happening is that the lack of a truecolor GLX framebuffer is preventing output to a truecolor visual.

I could probably get around this by creating a sub-window like with Xv. Can you try running bsnes and seeing if the OpenGL driver there produces an image? (obviously it isn't going to run at full speed)
Deathlike2
Snes9x Brown Belt
Posts: 1158
Joined: Mon Jan 10, 2005 6:34 am

Re: Segmentation Fault in Linux

Post by Deathlike2 »

mangamuscle wrote:I wonder if the latest version of snes9x-gtk requires OpenGL 2 since every time I choose OpenGL for hardware aceleration I get no graphics on screen (audio plays just fine) and if I activate either "alllow non power of two textures" and/or "use pixel buffer objects" the window closes with only a "segmentation fault" as error message.

I compiled my own binary without any problems.

My OpenGL version is 1.5 (works ok with Google Earth and Stella) and I am using Puppy Linux 4.1.2 w/GCC 4.2.2 on a one Ghz (fsb 133) pIII with an nvidia vanta card (using the latest nvidia drivers released for it).

Edit: I forgot to mention I am using SDL 1.2.14
The latter two features (the options you put in quotes) are specifically not available for your old hardware. You would need an FX card or better to even have the options.
Continuing FF4 Research...
mangamuscle
Snes9x White Belt
Posts: 13
Joined: Tue Feb 16, 2010 3:38 am

Post by mangamuscle »

BearOso wrote:Unfortunately, changing the display depth probably won't make a difference unless the nvidia drivers limit the available GLX visuals to that. GDK always creates a truecolor (24/32 bit) visual, and the OpenGL code in the program reuses the window GDK creates for its display. What might be happening is that the lack of a truecolor GLX framebuffer is preventing output to a truecolor visual.
I managed to change the color depth to 24 bit (for some reason 32 bit is unattainable in X) but even then I got no video output. This seems weird to me, here is the new info glxinfo gave in 24 bit mode:

Code: Select all

   visual  x  bf lv rg d st colorbuffer ax dp st accumbuffer  ms  cav
 id dep cl sp sz l  ci b ro  r  g  b  a bf th cl  r  g  b  a ns b eat
----------------------------------------------------------------------
0x21 24 tc  0 32  0 r  y  .  8  8  8  0  4 24  8 16 16 16 16  0 0 None
0x22 24 dc  0 32  0 r  y  .  8  8  8  0  4 24  8 16 16 16 16  0 0 None
0x23 24 tc  0 32  0 r  y  .  8  8  8  8  4 24  8 16 16 16 16  0 0 None
0x24 24 tc  0 32  0 r  .  .  8  8  8  0  4 24  8 16 16 16 16  0 0 None
0x25 24 tc  0 32  0 r  .  .  8  8  8  8  4 24  8 16 16 16 16  0 0 None
0x26 24 tc  0 32  0 r  y  .  8  8  8  0  4  0  0 16 16 16 16  0 0 None
0x27 24 tc  0 32  0 r  y  .  8  8  8  8  4  0  0 16 16 16 16  0 0 None
0x28 24 tc  0 32  0 r  .  .  8  8  8  0  4  0  0 16 16 16 16  0 0 None
0x29 24 tc  0 32  0 r  .  .  8  8  8  8  4  0  0 16 16 16 16  0 0 None
0x2a 24 dc  0 32  0 r  y  .  8  8  8  8  4 24  8 16 16 16 16  0 0 None
0x2b 24 dc  0 32  0 r  .  .  8  8  8  0  4 24  8 16 16 16 16  0 0 None
0x2c 24 dc  0 32  0 r  .  .  8  8  8  8  4 24  8 16 16 16 16  0 0 None
0x2d 24 dc  0 32  0 r  y  .  8  8  8  0  4  0  0 16 16 16 16  0 0 None
0x2e 24 dc  0 32  0 r  y  .  8  8  8  8  4  0  0 16 16 16 16  0 0 None
0x2f 24 dc  0 32  0 r  .  .  8  8  8  0  4  0  0 16 16 16 16  0 0 None
0x30 24 dc  0 32  0 r  .  .  8  8  8  8  4  0  0 16 16 16 16  0 0 None
I could probably get around this by creating a sub-window like with Xv. Can you try running bsnes and seeing if the OpenGL driver there produces an image? (obviously it isn't going to run at full speed)
I tried my best, but I cannot compile bsnes on this pc (only 4 gb hard disk, running low in free space) and I searched precompiled binaries but either they required glibc 2.7 or (version 0.55) ran without showing any video or sound at all (changed the available drivers in bsnes preferences menu to no avail).
Deathlike2 wrote:The latter two features (the options you put in quotes) are specifically not available for your old hardware. You would need an FX card or better to even have the options.
I undestand, but I think both options should be detected to be unavailable and presented as greyed out (unselectable).
Deathlike2
Snes9x Brown Belt
Posts: 1158
Joined: Mon Jan 10, 2005 6:34 am

Post by Deathlike2 »

Yea, sure. Obviously the options should be available when the extensions are available.
Continuing FF4 Research...
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

Deathlike2 wrote:Yea, sure. Obviously the options should be available when the extensions are available.
Simple reason: I can't check the extension string until the OpenGL driver is loaded, and it isn't loaded until the user hits Apply or OK to actually set the driver. The options aren't used if the extensions aren't found, though. I suppose the extension string check is what's somehow causing the segmentation fault.
mangamuscle wrote:I tried my best, but I cannot compile bsnes on this pc (only 4 gb hard disk, running low in free space) and I searched precompiled binaries but either they required glibc 2.7 or (version 0.55) ran without showing any video or sound at all (changed the available drivers in bsnes preferences menu to no avail).
This is probably related. I'll have to look and see what Stella does differently.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

I've updated the OpenGL driver in SVN. Instructions for checkout are here: http://code.google.com/p/snes9x-gtk/source/checkout. Since you mentioned you compiled your binary, I'm assuming you can compile this source, too.

This revision adds more robust error-checking. It's not going to fix anything, but if you run it from a terminal window, it'll tell you what I need to fix.
mangamuscle
Snes9x White Belt
Posts: 13
Joined: Tue Feb 16, 2010 3:38 am

Post by mangamuscle »

BearOso wrote:This revision adds more robust error-checking. It's not going to fix anything, but if you run it from a terminal window, it'll tell you what I need to fix.
I downloaded r292 and compiled it (needed some configuration files from the previous source I downloaded) and when I try to activate OpenGL mode all I get is an anti-climatic glxMakeCurrent Failed at the terminal window followed by the usual Segmentation Fault. I hope this proves to be useful.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

You're supposed to run the included autogen.sh script to generate those configuration files. :-)

I imagine the glXMakeCurrent failing was a BadMatch between the visuals. I've changed the code to create a new window with the visual rather than assuming it can do the color conversion. Could you try the latest SVN and see if it works now?
mangamuscle
Snes9x White Belt
Posts: 13
Joined: Tue Feb 16, 2010 3:38 am

Post by mangamuscle »

BearOso wrote: Could you try the latest SVN and see if it works now?
I downloaded the r293 source, ran autogen.sh, ./configure and make but I keep getting an error when compiling:

make[1]: *** No rule to make target `fxemu2b.o', needed by `snes9x-gtk'. Stop.

I did my best to try to fix it but I could not find the bloody bug :(
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

I don't know what's going on there because nothing has changed regarding the assembly cores.

For now, just add --without-assembler to the configure script. And make sure that it's a clean checkout, not on top of an older version.
mangamuscle
Snes9x White Belt
Posts: 13
Joined: Tue Feb 16, 2010 3:38 am

Post by mangamuscle »

BearOso wrote:For now, just add --without-assembler to the configure script. And make sure that it's a clean checkout, not on top of an older version.
I had deleted the directory where I downloaded r292 before downloading r293, so I just added --without-assembler and it compiled painlessly. OpenGL now shows graphics and the options "Allow non power of two textures" and "use pixel shader objets" do not crash the application (I don't know if they are really doing anything, frame rate is too bumpy). The only way I could crash the application was by selecting 32-bit (GL_BGRA) in the pixel-buffer format. In a few minutes I will test if this pattern repeats if I downgrade screen resolution to 16 bit (breakfast comes first!).

Acivating the GLSL shader option also crashes the application, but that was kind of expeting it to.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

mangamuscle wrote: I had deleted the directory where I downloaded r292 before downloading r293, so I just added --without-assembler and it compiled painlessly. OpenGL now shows graphics and the options "Allow non power of two textures" and "use pixel shader objets" do not crash the application (I don't know if they are really doing anything, frame rate is too bumpy). The only way I could crash the application was by selecting 32-bit (GL_BGRA) in the pixel-buffer format.
You _are_ getting pixel-buffer-objects support. It's in your extension string. (Note that this isn't shaders--it's just a fast way of uploading data) I think I know why it's crashing with 32-bit format, but there's really no way of checking whether or not the card supports it.
In a few minutes I will test if this pattern repeats if I downgrade screen resolution to 16 bit (breakfast comes first!).

Acivating the GLSL shader option also crashes the application, but that was kind of expeting it to.
It shouldn't have crashed there. I copied-and-pasted a section of code and forgot to change the string.
mangamuscle
Snes9x White Belt
Posts: 13
Joined: Tue Feb 16, 2010 3:38 am

Post by mangamuscle »

*after some tacos, cake and coffe for breakfast*
BearOso wrote:I think I know why it's crashing with 32-bit format, but there's really no way of checking whether or not the card supports it.
I think I misreported that, it is not crashing if I select 16 or 24 or 32 pixel-buffer format, until I load a game. In 16 bit depth resolution it crashes when I slect 16 bit pixel-buffer format (wtf!?) and in 24 bit depth resolution it crashes when in 16 or 32 bit pixel-buffer format O_o;
It shouldn't have crashed there. I copied-and-pasted a section of code and forgot to change the string.
... it definetively is crashing when I choose "Use GLSL shaders" (mind you, I do not load any vertex or fragment shader as I have neither), the problem is that the crashing is not consistent, sometimes it crashes the first time, other times I have to do it five times (when testing this option I did not had a game loaded). The only consistent behavior i that every time I try to activate it, it displays in the terminal window Cannot load GLSL shader functions.
User avatar
BearOso
Official GTK/Linux Porter/Dev
Posts: 460
Joined: Tue Oct 02, 2007 12:50 am

Post by BearOso »

mangamuscle wrote: ... it definetively is crashing when I choose "Use GLSL shaders" (mind you, I do not load any vertex or fragment shader as I have neither), the problem is that the crashing is not consistent, sometimes it crashes the first time, other times I have to do it five times (when testing this option I did not had a game loaded). The only consistent behavior i that every time I try to activate it, it displays in the terminal window Cannot load GLSL shader functions.
What I meant was that I fixed the bug and posted the change to SVN. If you try that code, it'll properly detect that the extension isn't there and not crash.

As far as the PBO depth issue is concerned--I'm not sure what the exact problem is, but the extension string is probably lying when it claims GL_EXT_pixel_buffer_object and GL_EXT_bgra because otherwise the 32-bit format would work every time.
mangamuscle
Snes9x White Belt
Posts: 13
Joined: Tue Feb 16, 2010 3:38 am

Post by mangamuscle »

BearOso wrote:What I meant was that I fixed the bug and posted the change to SVN. If you try that code, it'll properly detect that the extension isn't there and not crash.
Yep, downloaded r295 and no more crashes when trying to activate this option, albeit it would be nice if the Cannot load GLSL shader functions. appeared in a windows instead of in the terminal.

Though I still needed --without-assembler to create the binary; I forgot to mention last time, but when I use autogen.sh I get this error messages:

Code: Select all

Please add the files
  codeset.m4 gettext.m4 glibc21.m4 iconv.m4 isc-posix.m4 lcmessage.m4
  progtest.m4
from the /aclocal directory to your autoconf macro directory
or directly to your aclocal.m4 file.
You will also need config.guess and config.sub, which you can get from
ftp://ftp.gnu.org/pub/gnu/config/.

/usr/share/aclocal/nspr.m4:8: warning: underquoted definition of AM_PATH_NSPR
  run info '(automake)Extending aclocal'
  or see http://sources.redhat.com/automake/automake.html#Extending-aclocal
/usr/share/aclocal/audiofile.m4:12: warning: underquoted definition of AM_PATH_AUDIOFILE
Maybe this is related to the error that prevents me to compile normally the source?
As far as the PBO depth issue is concerned--I'm not sure what the exact problem is, but the extension string is probably lying when it claims GL_EXT_pixel_buffer_object and GL_EXT_bgra because otherwise the 32-bit format would work every time.
If I were using an ATI card I would say you are right, but NVIDIA's drivers are accurate AFAIK. I suppose there must be a reason that explains this odd behavior ... is there an SDL or OpenGL guru in the audience?
Post Reply