libretro / mame2003-libretro

MAME 0.78 for libretro. Compatible with MAME 0.78 sets.
Other
90 stars 75 forks source link

Segmentation fault in ym2151 #333

Closed ghost closed 6 years ago

ghost commented 6 years ago

game tested: term2 and related variations (probably also affects roms which uses ym2151)

-run game (term2 was what i tested). -calibrate the gun(if you are able to since this does now work correctly in mine) -just run demo(should crash about after the highscore screen) or just press START after inserting coins(this should crash immediately) (tested under linux with a clean mame directory and default core config)

related issue: https://github.com/libretro/mame2003-libretro/issues/323

Thread 1 "retroarch" received signal SIGSEGV, Segmentation fault.
0x00007fffd211ef49 in advance () at src/sound/ym2151.c:2179
2179                    (op+0)->phase += ( (PSG->freq[ kc_channel + (op+0)->dt2 ] + (op+0)->dt1) * (op+0)->mul ) >> 1;
(gdb) bt full
#0  0x00007fffd211ef49 in advance () at src/sound/ym2151.c:2179
        kc_channel = 4294967295
        mod_ind = -1
        op = 0x5555578eaab0
        i = 2
        a = 2
        p = -2
#1  0x00007fffd211f715 in YM2151UpdateOne (num=0, buffers=0x7fffffffddb0, 
    length=365) at src/sound/ym2151.c:2451
        i = 31
        outl = -1986
        outr = -1986
        bufL = 0x55555734a202
        bufR = 0x5555577e92f2
#2  0x00007fffd1845144 in streams_sh_update () at src/sound/streams.c:140
        buf = {0x55555734a202, 0x5555577e92f2, 0x1, 0xffffffff39a08cea, 
          0x7fffd180b234 <cpu_setopbase16>, 
          0x7fffd1800d06 <activecpu_get_reg+76>, 
          0x7fffd180b234 <cpu_setopbase16>, 
          0x7fffd1800d06 <activecpu_get_reg+76>, 0x200000009, 
          0xffffffffd1a53f60, 0x0, 0x7fffd1a53f60 <counter_value_r+18>, 
          0x5555578e9e78, 0x1578e9df0, 0xd30ab330, 
          0x7fffd18180ef <get_relative_time+9>}
---Type <return> to continue, or q <return> to quit---
        newpos = 902
        buflen = 365
        channel = 2
        i = 2
#3  0x00007fffd1844938 in sound_update () at src/sndintrf.c:1303
        totalsound = 4
#4  0x00007fffd1792c26 in updatescreen () at src/mame.c:1284
No locals.
#5  0x00007fffd1804c0c in cpu_vblankcallback (param=0) at src/cpuexec.c:1433
        cpunum = 2
#6  0x00007fffd181856c in timer_adjust_global_time (
    delta=3.3311276753655861e-07) at src/timer.c:336
        was_enabled = 1
        timer = 0x7fffd34e0840 <timers+1536>
#7  0x00007fffd18037de in cpu_timeslice () at src/cpuexec.c:666
        target = 3.3311276753655861e-07
        cpunum = 2
        ran = 33277
#8  0x00007fffd1802dbf in mame_frame () at src/cpuexec.c:375
No locals.
#9  0x00007fffd178f901 in retro_run () at src/libretro/libretro.c:570
        i = 4
        pointer_pressed = false
---Type <return> to continue, or q <return> to quit---
        thisInput = 0x7fffd28f6300 <retroKeys+2208>
        updated = false
#10 0x000055555559e800 in core_run ()
No symbol table info available.
#11 0x00005555555a3bcf in runloop_iterate ()
No symbol table info available.
#12 0x000055555559d650 in rarch_main ()
No symbol table info available.
#13 0x00007fffef808a87 in __libc_start_main (main=0x555555599410 <main>, 
    argc=1, argv=0x7fffffffe128, init=<optimized out>, fini=<optimized out>, 
    rtld_fini=<optimized out>, stack_end=0x7fffffffe118)
    at ../csu/libc-start.c:310
        result = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {0, 5796859508912778034, 
                93824992519616, 140737488347424, 0, 0, 371478566633171762, 
                371513120906636082}, mask_was_saved = 0}}, priv = {pad = {0x0, 
              0x0, 0x7fffffffe138, 0x7ffff7ffe170}, data = {prev = 0x0, 
              cleanup = 0x0, canceltype = -7880}}}
        not_first_call = <optimized out>
#14 0x000055555559a5ea in _start ()
No symbol table info available.

this segfault happens when mod_ind is < 0

ghost commented 6 years ago

this works fine in the raspberry pi what platform you using ?

ghost commented 6 years ago

https://github.com/grant2258/mame2003-libretro/commit/4f59c532b56409f3d99c4647a88d69c74a38501a

this should fix your problem on x64

ghost commented 6 years ago

nice find. that should work. please send the PR. thanks.

ghost commented 6 years ago

its already been pulled in here i dont have x64 retro arch setup yet so let me know how you get on

ghost commented 6 years ago

can we close this one too