gcc optimizations on amd64

Strictly for discussing ZSNES development and for submitting code. You can also join us on IRC at irc.libera.chat in #zsnes.
Please, no requests here.

Moderator: ZSNES Mods

Post Reply
jplien
New Member
Posts: 3
Joined: Tue Dec 21, 2010 2:55 am

gcc optimizations on amd64

Post by jplien »

I just spent the evening building zsnes 1.51 for Ubuntu Maverick (amd64). With 10.10 Ubuntu upgraded to libao4 which broke the previous zsnes package I had. The first time I built it I got a buffer overflow on startup. I still haven't tracked down the problem completely, but I discovered that if I build it with no compiler optimizations (-O0) it runs just fine. Any ideas? Performance seems fine on my AMD X2 2.5GHz.
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Re: gcc optimizations on amd64

Post by grinvader »

by 1.51 do you mean 1.51b ? if not, you know what to do.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
jplien
New Member
Posts: 3
Joined: Tue Dec 21, 2010 2:55 am

Re: gcc optimizations on amd64

Post by jplien »

Sorry, I only saw the 1.51b binaries the first time I looked at that thread. Rebuilt w/ 1.51b source this morning, same problem. Here is the console output of the crash (when built with -O3). If I build with -O1 the libao plugin errors go away but the buffer overflow still happens. If I build with -O0, it works.

Code: Select all

~/software/zsnes/zsnes_1_51b/src$ ./zsnes 
ERROR: Failed to load plugin /usr/lib/ao/plugins-4/libpulse.so => dlopen() failed
ERROR: Failed to load plugin /usr/lib/ao/plugins-4/libnas.so => dlopen() failed
ERROR: Failed to load plugin /usr/lib/ao/plugins-4/libalsa.so => dlopen() failed
ERROR: Failed to load plugin /usr/lib/ao/plugins-4/liboss.so => dlopen() failed
ERROR: Failed to load plugin /usr/lib/ao/plugins-4/libesd.so => dlopen() failed
ZSNES v1.51, (c) 1997-2007, ZSNES Team
Be sure to check http://www.zsnes.com/ for the latest version.

ZSNES is written by the ZSNES Team (See AUTHORS.TXT)
ZSNES comes with ABSOLUTELY NO WARRANTY.  This is free software,
and you are welcome to redistribute it under certain conditions;
please read 'LICENSE.TXT' thoroughly before doing so.

Use ZSNES -? for command line definitions.

This is a work in progress build. It contains code which
May or may not be complete

If this is supposed to be an official release, you forgot to
run configure with --enable-release, go rebuild.

Starting Mouse detection.
Unable to poll /dev/input/event3. Make sure you have read permissions to it.
Unable to poll /dev/input/event2. Make sure you have read permissions to it.
Unable to poll /dev/input/event1. Make sure you have read permissions to it.
Unable to poll /dev/input/event0. Make sure you have read permissions to it.
ManyMouse: 0 mice detected.
*** buffer overflow detected ***: ./zsnes terminated
======= Backtrace: =========
/lib32/libc.so.6(__fortify_fail+0x50)[0xf738ea80]
/lib32/libc.so.6(+0xe39ba)[0xf738d9ba]
./zsnes[0x805ad7f]
======= Memory map: ========
08048000-08346000 r-xp 00000000 08:14 4547579                            /home/jplien/software/zsnes/zsnes_1_51b/src/zsnes
08346000-08347000 r--p 002fd000 08:14 4547579                            /home/jplien/software/zsnes/zsnes_1_51b/src/zsnes
08347000-08386000 rw-p 002fe000 08:14 4547579                            /home/jplien/software/zsnes/zsnes_1_51b/src/zsnes
08386000-0893a000 rw-p 00000000 00:00 0 
0a099000-0a12b000 rw-p 00000000 00:00 0                                  [heap]
f4e63000-f5983000 rw-p 00000000 00:00 0 
f5983000-f598d000 r-xp 00000000 08:11 196487                             /lib32/libnss_files-2.12.1.so
f598d000-f598e000 r--p 00009000 08:11 196487                             /lib32/libnss_files-2.12.1.so
f598e000-f598f000 rw-p 0000a000 08:11 196487                             /lib32/libnss_files-2.12.1.so
f598f000-f59a2000 r-xp 00000000 08:11 196477                             /lib32/libnsl-2.12.1.so
f59a2000-f59a3000 r--p 00012000 08:11 196477                             /lib32/libnsl-2.12.1.so
f59a3000-f59a4000 rw-p 00013000 08:11 196477                             /lib32/libnsl-2.12.1.so
f59a4000-f59a6000 rw-p 00000000 00:00 0 
f59c3000-f59cc000 rw-p 00000000 00:00 0 
f59cc000-f59d0000 r-xp 00000000 08:12 74616                              /usr/lib32/libXdmcp.so.6.0.0
f59d0000-f59d1000 r--p 00003000 08:12 74616                              /usr/lib32/libXdmcp.so.6.0.0
f59d1000-f59d2000 rw-p 00004000 08:12 74616                              /usr/lib32/libXdmcp.so.6.0.0
f59d2000-f59d4000 r-xp 00000000 08:12 75823                              /usr/lib32/libXau.so.6.0.0
f59d4000-f59d5000 r--p 00001000 08:12 75823                              /usr/lib32/libXau.so.6.0.0
f59d5000-f59d6000 rw-p 00002000 08:12 75823                              /usr/lib32/libXau.so.6.0.0
f59d6000-f59ee000 r-xp 00000000 08:12 74601                              /usr/lib32/libxcb.so.1.1.0
f59ee000-f59ef000 r--p 00017000 08:12 74601                              /usr/lib32/libxcb.so.1.1.0
f59ef000-f59f0000 rw-p 00018000 08:12 74601                              /usr/lib32/libxcb.so.1.1.0
f59f0000-f59f1000 rw-p 00000000 00:00 0 
f59f1000-f59ff000 r-xp 00000000 08:12 74664                              /usr/lib32/libXext.so.6.4.0
f59ff000-f5a00000 r--p 0000d000 08:12 74664                              /usr/lib32/libXext.so.6.4.0
f5a00000-f5a01000 rw-p 0000e000 08:12 74664                              /usr/lib32/libXext.so.6.4.0
f5a01000-f5b1a000 r-xp 00000000 08:12 74575                              /usr/lib32/libX11.so.6.3.0
f5b1a000-f5b1b000 r--p 00118000 08:12 74575                              /usr/lib32/libX11.so.6.3.0
f5b1b000-f5b1d000 rw-p 00119000 08:12 74575                              /usr/lib32/libX11.so.6.3.0
f5b1d000-f5b1e000 rw-p 00000000 00:00 0 
f5b1e000-f714f000 r-xp 00000000 08:12 73845                              /usr/lib32/nvidia-current/libnvidia-glcore.so.260.19.06
f714f000-f71ab000 rwxp 01631000 08:12 73845                              /usr/lib32/nvidia-current/libnvidia-glcore.so.260.19.06
f71ab000-f71bb000 rwxp 00000000 00:00 0 
f71bb000-f71bc000 r-xp 00000000 08:12 73813                              /usr/lib32/nvidia-current/tls/libnvidia-tls.so.260.19.06
f71bc000-f71bd000 rw-p 00000000 08:12 73813                              /usr/lib32/nvidia-current/tls/libnvidia-tls.so.260.19.06
f71bd000-f71bf000 r-xp 00000000 08:11 196474                             /lib32/libdl-2.12.1.so
f71bf000-f71c0000 r--p 00001000 08:11 196474                             /lib32/libdl-2.12.1.so
f71c0000-f71c1000 rw-p 00002000 08:11 196474                             /lib32/libdl-2.12.1.so
f71c1000-f71c2000 rw-p 00000000 00:00 0 
f71c2000-f71c9000 r-xp 00000000 08:11 196501                             /lib32/librt-2.12.1.so
f71c9000-f71ca000 r--p 00006000 08:11 196501                             /lib32/librt-2.12.1.so
f71ca000-f71cb000 rw-p 00007000 08:11 196501                             /lib32/librt-2.12.1.so
f71cb000-f728c000 r-xp 00000000 08:12 73796                              /usr/lib32/libasound.so.2.0.0
f728c000-f7290000 r--p 000c0000 08:12 73796                              /usr/lib32/libasound.so.2.0.0
f7290000-f7291000 rw-p 000c4000 08:12 73796                              /usr/lib32/libasound.so.2.0.0
f7291000-f72a6000 r-xp 00000000 08:11 196496                             /lib32/libpthread-2.12.1.so
f72a6000-f72a7000 r--p 00014000 08:11 196496                             /lib32/libpthread-2.12.1.so
f72a7000-f72a8000 rw-p 00015000 08:11 196496                             /lib32/libpthread-2.12.1.so
f72a8000-f72aa000 rw-p 00000000 00:00 0 
f72aa000-f73fe000 r-xp 00000000 08:11 196304                             /lib32/libc-2.12.1.so
f73fe000-f73ff000 ---p 00154000 08:11 196304                             /lib32/libc-2.12.1.so
f73ff000-f7401000 r--p 00154000 08:11 196304                             /lib32/libc-2.12.1.so
f7401000-f7402000 rw-p 00156000 08:11 196304                             /lib32/libc-2.12.1.so
f7402000-f7405000 rw-p 00000000 00:00 0 
f7405000-f741f000 r-xp 00000000 08:12 73805                              /usr/lib32/libgcc_s.so.1
f741f000-f7420000 r--p 00019000 08:12 73805                              /usr/lib32/libgcc_s.so.1
f7420000-f7421000 rw-p 0001a000 08:12 73805                              /usr/lib32/libgcc_s.so.1
f7421000-f7445000 r-xp 00000000 08:11 196475                             /lib32/libm-2.12.1.so
f7445000-f7446000 r--p 00023000 08:11 196475                             /lib32/libm-2.12.1.so
f7446000-f7447000 rw-p 00024000 08:11 196475                             /lib32/libm-2.12.1.so
f7447000-f7448000 rw-p 00000000 00:00 0 
f7448000-f7527000 r-xp 00000000 08:12 73764                              /usr/lib32/libstdc++.so.6.0.14
f7527000-f752b000 r--p 000de000 08:12 73764                              /usr/lib32/libstdc++.so.6.0.14
f752b000-f752c000 rw-p 000e2000 08:12 73764                              /usr/lib32/libstdc++.so.6.0.14
f752c000-f7533000 rw-p 00000000 00:00 0 
f7533000-f75cf000 r-xp 00000000 08:12 73811                              /usr/lib32/nvidia-current/libGL.so.260.19.06
f75cf000-f75ed000 rwxp 0009b000 08:12 73811                              /usr/lib32/nvidia-current/libGL.so.260.19.06
f75ed000-f75fc000 rwxp 00000000 00:00 0 Aborted
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Re: gcc optimizations on amd64

Post by Nach »

This is just a guess, but you're using x86-64 OS, right?

If so, looks like you're getting the typical broken libao error. Use -ad sdl, or see here.


I'm not sure where the compiler optimizations come into play though. Perhaps when you used -O0, you also turned off libao.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
jplien
New Member
Posts: 3
Joined: Tue Dec 21, 2010 2:55 am

Re: gcc optimizations on amd64

Post by jplien »

Yes, I'm running a 64bit OS. I had read your thread about plugin links, and made one for the alsa.so plugin in /usr/lib/.

Code: Select all

$ ls -l /usr/lib/ao/plugins-4/
...
lrwxrwxrwx 1 root root    34 2010-12-20 20:20 libalsa-32.so -> /usr/lib32/ao/plugins-4/libalsa.so
...

If I run the -O3 binary with -ad sdl, or even -ad null it still crashes.

The working -O0 binary is configured/built with --enable-libao and the binary is linked to libao.so.4, but when I run it it opens the SDL audio driver. Only valid choices for -ad are sdl and auto.
Post Reply