Bug 1227807 - KoboDeluxe crashes when build with gcc-5
Summary: KoboDeluxe crashes when build with gcc-5
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: KoboDeluxe
Version: 22
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Hans de Goede
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2015-06-03 14:20 UTC by Hans de Goede
Modified: 2015-06-18 13:19 UTC (History)
6 users (show)

Fixed In Version: KoboDeluxe-0.5.1-18.fc22
Clone Of:
Environment:
Last Closed: 2015-06-18 13:19:04 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Hans de Goede 2015-06-03 14:20:08 UTC
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

Comment 1 Marek Polacek 2015-06-03 14:33:08 UTC
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.

Comment 2 Hans de Goede 2015-06-03 18:19:41 UTC
(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.

Comment 3 Jakub Jelinek 2015-06-03 18:25:05 UTC
-fsanitize=undefined needs to be used not just for compilation, but also when linking.  And, libubsan package needs to be installed.

Comment 4 Hans de Goede 2015-06-03 18:57:47 UTC
(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.

Comment 5 Fedora Update System 2015-06-05 11:11:00 UTC
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

Comment 6 Fedora Update System 2015-06-07 15:59:03 UTC
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).

Comment 7 Fedora Update System 2015-06-18 13:19:04 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.