Crash when closing widelands

Bug #1150517 reported by Gabriel Margiani
16
This bug affects 2 people
Affects Status Importance Assigned to Milestone
widelands
Fix Released
Medium
Kiscsirke

Bug Description

When closing wl r6527(debug) using the exit button in the menu or Alt-F4 (o. eq.) (doesn't happen while splash screen is being shown)

System OpenSuse 12.2.

According to the output, the crash seems to be triggered in sound code.

[...]
SurfaceCache: inserted pics/but3.png, now using 4,91 mb.
SurfaceCache: inserted pics/mainmenu.jpg:800:600, now using 6,74 mb.
Sound_Handler: loaded song "music/menu_00.ogg"
Sound_Handler closing times 1, freq 22050, format 32784, chan 2
SDL_AUDIODRIVER pulse
*** glibc detected *** /home/gabriel/checkouts/wl/wl1/widelands: corrupted double-linked list: 0x08c512f0 ***
[Thread 0xb2e03b40 (LWP 7817) exited]
======= Backtrace: =========
/lib/libc.so.6(+0x72ac2)[0xb7aa8ac2]
/lib/libc.so.6(+0x72e12)[0xb7aa8e12]
/lib/libc.so.6(+0x736e5)[0xb7aa96e5]
/usr/lib/libogg.so.0(ogg_stream_clear+0x26)[0xb74c5a76]
/usr/lib/libvorbisfile.so.3(ov_clear+0x44)[0xb756d564]
/usr/lib/libSDL_mixer-1.2.so.0(OGG_delete+0x3f)[0xb7ea99ef]
/usr/lib/libSDL_mixer-1.2.so.0(Mix_FreeMusic+0x9b)[0xb7e9baab]
/home/gabriel/checkouts/wl/wl1/widelands(_ZN7SongsetD2Ev+0x2a)[0x87ee9ac]
/home/gabriel/checkouts/wl/wl1/widelands(_ZN13Sound_HandlerD1Ev+0x8b)[0x87e8757]
/lib/libc.so.6(+0x31341)[0xb7a67341]
/lib/libc.so.6(+0x313cd)[0xb7a673cd]
/lib/libc.so.6(__libc_start_main+0xfd)[0xb7a4f3dd]
/home/gabriel/checkouts/wl/wl1/widelands[0x8580261]
======= Memory map: ========
08048000-08bd7000 r-xp 00000000 08:02 1835527 /home/gabriel/checkouts/wl/wl1/widelands
08bd7000-08bd8000 r--p 00b8e000 08:02 1835527 /home/gabriel/checkouts/wl/wl1/widelands
08bd8000-08bd9000 rw-p 00b8f000 08:02 1835527 /home/gabriel/checkouts/wl/wl1/widelands
08bd9000-08f47000 rw-p 00000000 00:00 0 [heap]
b13e6000-b1632000 rw-p 00000000 00:00 0
b2419000-b2459000 r-xp 00000000 08:01 1319732 /usr/lib/libjpeg.so.62.0.0
b2459000-b245a000 r--p 0003f000 08:01 1319732 /usr/lib/libjpeg.so.62.0.0
b245a000-b245b000 rw-p 00040000 08:01 1319732 /usr/lib/libjpeg.so.62.0.0
b245b000-b246b000 rw-p 00000000 00:00 0
b248e000-b24da000 r-xp 00000000 08:01 1319707 /usr/lib/libmikmod.so.2.0.4
b24da000-b24db000 r--p 0004b000 08:01 1319707 /usr/lib/libmikmod.so.2.0.4
b24db000-b24dc000 rw-p 0004c000 08:01 1319707 /usr/lib/libmikmod.so.2.0.4
b24dc000-b24dd000 rw-p 00000000 00:00 0
b2500000-b2521000 rw-p 00000000 00:00 0
b2521000-b2600000 ---p 00000000 00:00 0
b2603000-b2604000 ---p 00000000 00:00 0
b2604000-b2e04000 rw-p 00000000 00:00 0
b6e05000-b6f6b000 r-xp 00000000 08:01 1320680 /usr/lib/libvorbisenc.so.2.0.9
b6f6b000-b6f7c000 r--p 00165000 08:01 1320680 /usr/lib/libvorbisenc.so.2.0.9
b6f7c000-b6f7d000 rw-p 00176000 08:01 1320680 /usr/lib/libvorbisenc.so.2.0.9
b6f7d000-b6fba000 r-xp 00000000 08:01 1320344 /usr/lib/libFLAC.so.8.2.0
b6fba000-b6fbb000 r--p 0003c000 08:01 1320344 /usr/lib/libFLAC.so.8.2.0
[...]
b7bdc000-b7bf8000 r-xp 00000000 08:01 540879 /lib/libgcc_s.so.1
b7bf8000-b7bf9000 r--p 0001b000 08:01 540879
Program received signal SIGABRT, Aborted.
0xb7fdc430 in __kernel_vsyscall ()

I can post the full output if someone needs it.

Tags: crash

Related branches

Revision history for this message
Kiscsirke (csirkeee) wrote :

I fixed a memory bug around there, could you see if you still have a problem with current trunk?

Thank you!

Revision history for this message
Hans Joachim Desserud (hjd) wrote :

If the issue persists (or for future bug reports) please include which operating system you are running.

Changed in widelands:
milestone: none → build18-rc1
summary: - Creash when closing widelands
+ Crash when closing widelands
tags: added: crash
Revision history for this message
Gabriel Margiani (gamag) wrote :

sorry that I forgot my OS. OpenSuse 12.2, 32bit. I don't think this makes any difference in this case.

The crash persists and is actually triggered by the line Mix_FreeMusik(m_m) Songset::~Songset. Or at least, the crash can be avoided by removing this line. Maybe it is called once after the Mix system has be shut down while closing wl. I don't really know the code there, so I didn't fix it.

description: updated
Revision history for this message
Kiscsirke (csirkeee) wrote :

Okay, thank you for the report, I have an idea what might cause this.

Could you try the branch lp:~csirkeee/widelands/bug1150517 ?

(If it works I'll do some refactoring around it before commiting to trunk, but first I want to know whether this is the problem.)

Revision history for this message
Hans Joachim Desserud (hjd) wrote :

>sorry that I forgot my OS. OpenSuse 12.2, 32bit. I don't think this makes any difference in this case.

For most bugs it doesn't, as they are usually reproducible on all platforms. In this case however, I've been unable to trigger this crash on Ubuntu 12.10 (64bit), and another user on IRC didn't see it on gentoo either.

Keep in mind that different distributions/platforms might ship with different version of libraries making them slightly different in subtle ways. Some might even have patched the libraries in various ways. This means that sometimes others will need to know and be able to reproduce the exact environment WL is running in to be able to reproduce the issue. A common example is bugs revealed by newer releases which initially affect only a few system, but as the newer version is rolled out it will eventually affect all (for instance bug 976551). Therefore I would encourage you to include a mention of your operating system and version along with the version of Widelands in case it is relevant.

Revision history for this message
Gabriel Margiani (gamag) wrote :

ok. if you can't reproduce it, it may be a problem of sdl. And I'll have to fix it in wl, since nobody can fix something he can't test.

@Kiscsirke - Thaks for your effort, but it doesn't work. Seems that I was wrong with Mix_FreeMusic() causing the crash, or there where two problems and you fixed one.

Now the crash happens even after a music has finished in game. And new tests have shown, that it is triggered in SDL_FreeRW.

Maybe it has something to do with SDL_Mixer freeing automaticaly.

But since it seems to be an OpenSuse specific bug, lets wait if it disappears, or appears on other systems too. (Maybe your fix is good anyway, I don't know.)

Changed in widelands:
status: New → Triaged
Revision history for this message
Kiscsirke (csirkeee) wrote :

Or it might be that we're using SDL the wrong way, but sometimes it works anyway :)

If it's no problem, can you show a stack trace showing which SDL_FreeRW causes the crash now? (Even without testing, if I look at the problematic line, it might become obvious what the problem is.)

Revision history for this message
Gabriel Margiani (gamag) wrote :

When closing widelands, it's the call in the destructor of songset.
When a music has reached its end It's the other one:

*** glibc detected *** ./widelands: double free or corruption (fasttop): 0x0a531a60 ***
======= Backtrace: =========
/lib/libc.so.6(+0x72ac2)[0xb71b1ac2]
/usr/lib/libSDL-1.2.so.0(SDL_FreeRW+0x1b)[0xb762ff4b]
./widelands(_ZN7Songset8get_songEv+0x163)[0x87f02b5]
./widelands(_ZN13Sound_Handler11start_musicERKSsi+0xca)[0x87ebaaa]
./widelands(_ZN13Sound_Handler12change_musicERKSsii+0xa6)[0x87ebc06]
./widelands(_ZN13WLApplication10poll_eventER9SDL_Eventb+0x168)[0x858372c]
./widelands(_ZN13WLApplication12handle_inputEPK13InputCallback+0x504)[0x8583d98]
./widelands(_ZN2UI5Panel3runEv+0x1bf)[0x86411d7]
./widelands(_ZN9Widelands4Game3runEPN2UI14ProgressWindowENS0_15Start_Game_TypeE+0x7a2)[0x87041c0]
./widelands(_ZN13WLApplication8new_gameEv+0x32f)[0x85889e9]
./widelands(_ZN13WLApplication21mainmenu_singleplayerEv+0x64)[0x8587fde]
./widelands(_ZN13WLApplication8mainmenuEv+0x1a0)[0x8587b82]
./widelands(_ZN13WLApplication3runEv+0x934)[0x8583156]
./widelands(main+0x2f9)[0x8581605]
/lib/libc.so.6(__libc_start_main+0xf5)[0xb71583d5]
./widelands[0x8581241]

Revision history for this message
Kiscsirke (csirkeee) wrote :

Ok, I looked into it (quite) a bit now, and it seems like (according to this http://www.idevgames.com/forums/thread-3837.html for example) SDL_mixer used to free the RWs given to it by Mix_LoadMUS_RW. (RWs are a kind of memory structure used all over SDL.) Other functions generally don't free RWs passed to them, and in version 1.2.12 this function changed to that behavior too as default.

So, if you can confirm that you have an older version of SDL_mixer then 1.2.12, the solution is to update. (Though I still don't know why it didn't cause a problem before, we've been doing it this way from before SDL_mixer 1.2.12 came out.)

If this really is the problem, we might put in a check to CMAKE to make sure SDL_mixer is a recent version, so others won't run on this problem in the future.

Revision history for this message
Gabriel Margiani (gamag) wrote :

Ok, updating really helps. (OpenSuse has only 1.2.11 in it's standard repo)

> (Though I still don't know why it didn't cause a problem before,
> we've been doing it this way from before SDL_mixer 1.2.12 came out.)
You introduced all FreeRW calls in r6518

Sorry for the trouble.

Revision history for this message
Kiscsirke (csirkeee) wrote :

Right, sorry, I was looking at the old code for it today, and we did have the FreeRW calls until r3252, then they were removed. Glad that it works now.

QCS: Can we put in a guard to warn if SDL_Mixer version is < 1.2.12? Thanks!

Changed in widelands:
assignee: nobody → Jens Beyer (Qcumber-some) (qcumber-some)
Kiscsirke (csirkeee)
Changed in widelands:
assignee: Jens Beyer (Qcumber-some) (qcumber-some) → Kiscsirke (csirkeee)
Revision history for this message
Canseco (machaquiro) wrote :

I had the same problem with OpenPandora.
Compiled with SDL_mixer 1.2.12 and problem solved, thx.

Revision history for this message
l p (l-p) wrote :

Ubuntu 12.04 LTS ships SDL_mixer 1.2.11-7, and is affected by this bug as well.

Alternate fix is to turn off the music.

Revision history for this message
Jens Beyer (qcumber-some) wrote :

This is more serious, *buntu will probably not update the LTS version to 1.2.12 - they will only update bugfixes, sometimes not even that, making software unusable which was running before.

Revision history for this message
Kiscsirke (csirkeee) wrote :

Ok, lp:~csirkeee/widelands/bug1150517_3 checks SDL_Mixer version in code, could someone with older version test that it works? Would that be an acceptable solution for everybody, until the old version of SDL_Mixer can be safely deprecated?

Revision history for this message
l p (l-p) wrote :

Tried the patch on Ubuntu 12.04.2 LTS, which ships sdl-mixer 1.2.11-7.
1. Started a game, waited song to change, exited the game completely, no crash dump. That was my original bug that is marked as duplicate.
2. Started a game, exited from main menu with Alt+F4, no crash dump. That would be the scenario in this report.

Revision history for this message
SirVer (sirver) wrote :

Seems like this can then be merged?

Kiscsirke (csirkeee)
Changed in widelands:
status: Triaged → Fix Committed
Revision history for this message
SirVer (sirver) wrote :

Released in build-18 rc1.

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.