Hi, I know you like small reproducers for bugs like this, but I'm afraid I cannot really help there. While tracking down a bug in KoboDeluxe (a game in Fedora), gdb was pointing to code which looks fine, so in a desperate move I tried recompiling the .c file in question with -O instead of -O2, and the bug went away, rebuilding the file again the exact same way but no with -O2 and the bug is back... The file in question is audio/a_midicon.c amd here is the backtrace when building with -O2 : __press (key=89, ch=5) at a_midicon.c:123 123 m[ch].next[m[ch].last] = (char)key; Thread 3 (Thread 0x7fffe5798700 (LWP 12357)): #0 __press (key=89, ch=5) at a_midicon.c:123 #1 midicon_note_on (ch=5, pitch=89, vel=<optimized out>) at a_midicon.c:176 #2 0x000000000043f6cd in mp_update (mp=mp@entry=0x1048f90) at a_midifile.c:473 #3 0x000000000043fe3b in mp_play (mp=0x1048f90, dt=0,00142670376) at a_midifile.c:679 #4 0x0000000000443057 in sequencer_process (frames=frames@entry=128) at a_sequencer.c:101 ... To reproduce do: fedpkg clone KoboDeluxe cd KoboDeluxe edit KoboDeluxe.spec, remove the workaround I'm about to add for this fedpkg local cd Kobodeluxe-0.5.1 gdb ./kobodl run -nofullscreen Note the -nofullscreen is important! Wait a few seconds at the welcome screen, then you will get the backtrace in question, now do: touch sound/a_midicon.c make CFLAGS="-g -O -Wall -I/usr/include/SDL" ./kobodl -nofullscreen Works like a charm, then do: touch sound/a_midicon.c make CFLAGS="-g -O2 -Wall -I/usr/include/SDL" ./kobodl -nofullscreen And the bug is back. This was all done on a f22 system with gcc-5.1.1-1.fc22.x86_64 Regards, Hans
Can you please try building with -O2 -fno-strict-aliasing? If that doesn't help then try -fwrapv and/or -fno-aggressive-loop-optimizations. Also consider recompiling with -fsanitize=undefined.
(In reply to Marek Polacek from comment #1) > Can you please try building with -O2 -fno-strict-aliasing? > If that doesn't help then try -fwrapv and/or > -fno-aggressive-loop-optimizations. I've tried all of the above (one by one) and none of them help. > Also consider recompiling with -fsanitize=undefined. This leads to: /home/hans/projects/fedora/KoboDeluxe/master/KoboDeluxe-0.5.1/sound/a_midicon.c:227: undefined reference to `__ubsan_handle_type_mismatch' /home/hans/projects/fedora/KoboDeluxe/master/KoboDeluxe-0.5.1/sound/a_midicon.c:227: undefined reference to `__ubsan_handle_out_of_bounds' And then a ton more of those.
-fsanitize=undefined needs to be used not just for compilation, but also when linking. And, libubsan package needs to be installed.
(In reply to Jakub Jelinek from comment #3) > -fsanitize=undefined needs to be used not just for compilation, but also > when linking. And, libubsan package needs to be installed. Thanks, that did the trick, good news, this option shows that this is a bug in the game and not in gcc-5, the problem is that a negative array index was being used. The use of -fsanitize=undefined is a cool trick btw, I'll try to remember this, Updating this bug to reflect this.
KoboDeluxe-0.5.1-18.fc22 has been submitted as an update for Fedora 22. https://admin.fedoraproject.org/updates/KoboDeluxe-0.5.1-18.fc22
Package KoboDeluxe-0.5.1-18.fc22: * should fix your issue, * was pushed to the Fedora 22 testing repository, * should be available at your local mirror within two days. Update it with: # su -c 'yum update --enablerepo=updates-testing KoboDeluxe-0.5.1-18.fc22' as soon as you are able to. Please go to the following url: https://admin.fedoraproject.org/updates/FEDORA-2015-9576/KoboDeluxe-0.5.1-18.fc22 then log in and leave karma (feedback).
KoboDeluxe-0.5.1-18.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.