ericmckean / game-music-emu

Automatically exported from code.google.com/p/game-music-emu
GNU Lesser General Public License v2.1
0 stars 0 forks source link

certain GBS file causes SIGSEGV in the library #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. download the file http://www.zophar.net/download_file/15402
2. try to play it using gme 0.5.2, 0.5.5 or current svn

What is the expected output? What do you see instead?

it causes SIGSEGV. this is the backtrace created using demo player from svn.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb72d6b70 (LWP 16485)]
0xb7ed8215 in Gb_Cpu::run(long) () from ./libgme.so.0
(gdb) bt
#0  0xb7ed8215 in Gb_Cpu::run(long) () from ./libgme.so.0
#1  0xb7edaa52 in Gbs_Emu::run_clocks(int&, int) () from ./libgme.so.0
#2  0xb7ec3c36 in Classic_Emu::play_(long, short*) () from ./libgme.so.0
#3  0xb7ecc2b1 in Music_Emu::emu_play(long, short*) () from ./libgme.so.0
#4  0xb7ecc3c3 in Music_Emu::fill_buf() () from ./libgme.so.0
#5  0xb7ecc580 in Music_Emu::play(long, short*) () from ./libgme.so.0
#6  0xb7ec894a in gme_play () from ./libgme.so.0
#7  0x08049b82 in Music_Player::fill_buffer(void*, short*, int) ()
#8  0x08049bea in sdl_callback(void*, unsigned char*, int) ()
#9  0xb7f1d029 in ?? () from /usr/lib/libSDL-1.2.so.0
#10 0xb7f25861 in ?? () from /usr/lib/libSDL-1.2.so.0
#11 0xb7f6f67b in ?? () from /usr/lib/libSDL-1.2.so.0
#12 0xb7bf2cf7 in start_thread () from /lib/libpthread.so.0
#13 0xb7cde86e in clone () from /lib/libc.so.6
Backtrace stopped: Not enough registers or memory available to unwind further
(gdb)

i don't know how to force cmake to build with debug, so made another backtrace 
using my app:

#0  Gb_Cpu::run (this=0x81e6ad4, cycle_count=209715)
    at game-music-emu-svn/gme/Gb_Cpu.cpp:137
#1  0xb4b9922a in Gbs_Emu::run_clocks (this=0x81e6988, duration=@0xb350011c)
    at game-music-emu-svn/gme/Gbs_Emu.cpp:246
#2  0xb4b9b808 in Classic_Emu::play_ (this=0x81e6988, count=2048, out=0x8178230)
    at game-music-emu-svn/gme/Classic_Emu.cpp:113
#3  0xb4ba63f0 in emu_play (out=0x8178230, count=2048, this=0x81e6988)
    at game-music-emu-svn/gme/Music_Emu.cpp:295
#4  Music_Emu::emu_play (this=0x81e6988, count=2048, out=0x8178230)
    at game-music-emu-svn/gme/Music_Emu.cpp:290
#5  0xb4ba647a in Music_Emu::fill_buf (this=0x81e6988)
    at game-music-emu-svn/gme/Music_Emu.cpp:317
#6  0xb4ba6758 in Music_Emu::play (this=0x81e6988, out_count=2048, 
out=0xb3500270)
    at game-music-emu-svn/gme/Music_Emu.cpp:351
#7  0xb4b9c88b in gme_play (me=0x81e6988, n=2048, p=0xb3500270)
    at game-music-emu-svn/gme/gme.cpp:336

What version of the product are you using? On what operating system?

game music emu 0.5.2, 0.5.5, svn r33
linux (x86,x86_64) and android (arm)

Please provide any additional information below.

the same file plays flawlessly in foobar2000, so it might be some difference 
between linux/windows, or foo_gep has a patch for this problem.

Original issue reported on code.google.com by waker...@gmail.com on 19 Nov 2011 at 2:30

GoogleCodeExporter commented 9 years ago
i've found out that fb2k uses game music emu 0.6pre, and kode54 has source code 
for it here: http://kode54.foobar2000.org/Game_Music_Emu-0.6-pre.tbz

it's missing few files, which i took from svn r33, then i compiled my app with 
it, and now this GBS file doesn't crash.

is there any official way to grab the gme 0.6pre?

Original comment by waker...@gmail.com on 19 May 2012 at 11:44

GoogleCodeExporter commented 9 years ago
i've found another misterious version of gme here:
ftp://ftp.archlinux.org/other/game-music-emu/

it claims to be 0.6.0, but in changelog it says 0.5.6

it also claims that it fixes some GBS bug:

Game_Music_Emu 0.5.6
--------------------
.....
- Fixed a couple of GBS bugs, one involving access of memory after realloc.

but it doesn't affect the "Grandia - Parallel Trippers" crash, while foo_gep's 
gme0.6pre handles it without any problems.

can someone explain existance of these 0.6x source archives outside of the 
official website/svn?

Original comment by waker...@gmail.com on 19 May 2012 at 12:32

GoogleCodeExporter commented 9 years ago
We had been working on an 0.6.0 but never released one. I would assume the ones 
you're seeing are forks of the 0.6.0-pre release with various patches applied 
because we suck at making releases ourselves. :(

Original comment by michael....@gmail.com on 16 Mar 2013 at 9:17

GoogleCodeExporter commented 9 years ago
I'm going through now and doing the "yearly cleanup", tried testing current SVN 
(which is essentially *our* 0.6.0) with the Grandia Parallel Trippers GBS on 
the libgme demo, no crash. I tried grabbing the song linked to at ZD but the 
URL is broken now (song seems to be removed), and I'm not sure what game it was 
from to test.

BTW, to build with Debug info on CMake you can add -DCMAKE_BUILD_TYPE=Debug 
(debug; no optimizations) or -DCMAKE_BUILD_TYPE=RelWithDebInfo (debug + 
optimizations) when running cmake.

From reviewing the svn log for Gbs_Emu.cpp the "use-after-realloc" was fixed 
immediately after 0.5.5, but the next release (0.6.0) wasn't until nearly 3.5 
years afterward. That might explain Grandia being fixed, but if you had tested 
SVN when you opened this report then GBS still has whatever bug that was, so 
I'd appreciate it if you can track down the song that caused the failure (or 
where the "working" foobar libgme went so I can compare the two files).

Original comment by michael....@gmail.com on 23 Jun 2014 at 4:26

GoogleCodeExporter commented 9 years ago
I don't think I'll be able to test upstream libGME in the nearest few weeks. 
But the version of libGME which I use is here: 
https://github.com/Alexey-Yakovenko/deadbeef/tree/master/plugins/gme/game-music-
emu-0.6pre

it's almost 100% identical to the one on kode54 website, + few portability 
fixes.

Original comment by waker...@gmail.com on 23 Jun 2014 at 8:07