libretro / parallel-n64

Optimized/rewritten Nintendo 64 emulator made specifically for Libretro. Originally based on Mupen64 Plus.
319 stars 127 forks source link

Segfaults in x86 if compiled with dynarec support #256

Open sergiobenrocha2 opened 9 years ago

sergiobenrocha2 commented 9 years ago

It's segfaulting if you compile it with dynarec support for x86, and try load a game with mupen64-cpucore = "cached_interpreter":

Program received signal SIGSEGV, Segmentation fault.
audio_convert_s16_to_float_SSE2 (out=0x827de88, in=0xb21f1540 <g_rdram+1897472>, samples=320, gain=1)
    at mupen64plus-core/src/plugin/audio_libretro/audio_utils.c:89
89     __m128 factor = _mm_set1_ps(fgain);
(gdb) bt full
#0  audio_convert_s16_to_float_SSE2 (out=0x827de88, in=0xb21f1540 <g_rdram+1897472>, samples=320, gain=1)
    at mupen64plus-core/src/plugin/audio_libretro/audio_utils.c:89
        fgain = 4.65661287e-10
        factor = {5.60519386e-45, -6.24618401e-09, 5.07302587e-34, -6.24617691e-09}
        i = 0
#1  0xb1e407d3 in push_audio_samples_via_libretro (user_data=0x0, buffer=0xb21f1540 <g_rdram+1897472>, 
    size=640) at mupen64plus-core/src/plugin/audio_libretro/audio_backend_libretro.c:155
        out = 0x0
        max_frames = 1485
        remain_frames = 0
        i = 640
        ratio = 1.3778666500031245
        data = {data_in = 0x827de88, data_out = 0x8281e90, input_frames = 160, output_frames = 0, 
          ratio = 1.3778666500031245}
        len = 640
        raw_data = 0xb21f1540 <g_rdram+1897472>
        frames = 160
        p = 0xb21f1540 <g_rdram+1897472> ""
        saved_ai_length = 640
        saved_ai_dram = 1897472
#2  0xb1de8bbb in push_audio_samples (backend=0xb2021b14 <g_ai+52>, buffer=0xb21f1540 <g_rdram+1897472>, 
    size=640) at mupen64plus-core/src/api/audio_backend.c:79
No locals.
#3  0xb1e226d2 in do_dma (ai=0xb2021ae0 <g_ai>, dma=0xb2021af8 <g_ai+24>)
    at mupen64plus-core/src/ai/ai_controller.c:101
No locals.
#4  0xb1e22794 in fifo_push (ai=0xb2021ae0 <g_ai>) at mupen64plus-core/src/ai/ai_controller.c:129
        duration = 236655
#5  0xb1e2291b in write_ai_regs (opaque=0xb2021ae0 <g_ai>, address=2756706308, value=640, 
    mask=4294967295) at mupen64plus-core/src/ai/ai_controller.c:184
        ai = 0xb2021ae0 <g_ai>
        reg = 1
#6  0xb1df392d in writew (write_word=0xb1e228a9 <write_ai_regs>, opaque=0xb2021ae0 <g_ai>, 
    address=2756706308, value=640) at mupen64plus-core/src/memory/m64p_memory.c:159
No locals.
#7  0xb1df561d in write_ai () at mupen64plus-core/src/memory/m64p_memory.c:704
No locals.
#8  0xb1e04eed in SW () at mupen64plus-core/src/r4300/interpreter_r4300.def:447
        lsaddr = 2756706308
        lsrtp = 0xb37253a8 <reg+104>
---Type <return> to continue, or q <return> to quit---
#9  0xb1e25c9e in pc_ops_wrapper () at mupen64plus-core/src/r4300/r4300.c:348
No locals.
#10 0xb1e25d10 in r4300_execute () at mupen64plus-core/src/r4300/r4300.c:363
No locals.
#11 0xb1deaadc in main_run () at mupen64plus-core/src/main/main.c:466
No locals.
#12 0xb1e39701 in EmuThreadFunction () at libretro/libretro.c:369
No locals.
#13 0xb1dcaab0 in co_init () at libretro/libco/x86.c:63
        addr = 0
        base = 0
        size = 0
#14 0x00000000 in ?? ()
No symbol table info available.

With "mupen64-cpucore = dynamic_recompiler" it will shows only a black screen, but you can back to RGUI.

Tested on ubuntu 14.04

sergiobenrocha2 commented 9 years ago
(gdb) thread apply all bt full

Thread 7 (Thread 0xa6c3eb40 (LWP 31718)):
#0  0xb7fdd424 in __kernel_vsyscall ()
No symbol table info available.
#1  0xb78f95f6 in nanosleep () at ../sysdeps/unix/syscall-template.S:81
No locals.
#2  0x080610d3 in rarch_sleep (msec=10) at ./libretro-common/include/retro_miscellaneous.h:103
        tv = {tv_sec = 0, tv_nsec = 10000000}
#3  0x08061323 in data_thread_loop (data=0x8218340 <g_data_runloop>) at runloop_data.c:182
        runloop = 0x8218340 <g_data_runloop>
#4  0x0811b906 in thread_wrap (data_=0x877dc78) at libretro-common/rthreads/rthreads.c:89
        data = 0x877dc78
#5  0xb78f1f70 in start_thread (arg=0xa6c3eb40) at pthread_create.c:312
        __res = <optimized out>
        pd = 0xa6c3eb40
        now = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {-1215283200, -1497109696, 4001536, -1497111512, 
                -639210386, 1075769932}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, 
            data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#6  0xb689470e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129
No locals.

Thread 6 (Thread 0xa7603b40 (LWP 31717)):
#0  0xb7fdd424 in __kernel_vsyscall ()
No symbol table info available.
#1  0xb68857ab in poll () at ../sysdeps/unix/syscall-template.S:81
No locals.
#2  0xb79dcbbd in ?? () from /usr/lib/i386-linux-gnu/libpulse.so.0
No symbol table info available.
#3  0xb79cb4ee in pa_mainloop_poll () from /usr/lib/i386-linux-gnu/libpulse.so.0
No symbol table info available.
#4  0xb79cbd1d in pa_mainloop_iterate () from /usr/lib/i386-linux-gnu/libpulse.so.0
No symbol table info available.
#5  0xb79cbdf4 in pa_mainloop_run () from /usr/lib/i386-linux-gnu/libpulse.so.0
No symbol table info available.
#6  0xb79dcb5c in ?? () from /usr/lib/i386-linux-gnu/libpulse.so.0
No symbol table info available.
#7  0xb66474dd in ?? () from /usr/lib/i386-linux-gnu/pulseaudio/libpulsecommon-4.0.so
No symbol table info available.
#8  0xb78f1f70 in start_thread (arg=0xa7603b40) at pthread_create.c:312
        __res = <optimized out>
        pd = 0xa7603b40
        now = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {-1215283200, -1486865600, 4001536, -1486867416, 
                -1639551891, 1075769932}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, 
            data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#9  0xb689470e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129
No locals.

Thread 5 (Thread 0xad1b1b40 (LWP 31680)):
#0  0xb7fdd424 in __kernel_vsyscall ()
No symbol table info available.
#1  0xb78f5d4b in pthread_cond_wait@@GLIBC_2.3.2 ()
    at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_wait.S:187
No locals.
#2  0xb1258cd4 in ?? () from /usr/lib/i386-linux-gnu/dri/swrast_dri.so
No symbol table info available.
#3  0xb1257e67 in ?? () from /usr/lib/i386-linux-gnu/dri/swrast_dri.so
No symbol table info available.
#4  0xb78f1f70 in start_thread (arg=0xad1b1b40) at pthread_create.c:312
        __res = <optimized out>
        pd = 0xad1b1b40
        now = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {-1215283200, -1390732480, 4001536, -1390734296, 
                1745251449, 1075769932}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, 
            data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#5  0xb689470e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129
No locals.

Thread 4 (Thread 0xad9b2b40 (LWP 31679)):
#0  0xb7fdd424 in __kernel_vsyscall ()
No symbol table info available.
#1  0xb78f5d4b in pthread_cond_wait@@GLIBC_2.3.2 ()
    at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_wait.S:187
No locals.
#2  0xb1258cd4 in ?? () from /usr/lib/i386-linux-gnu/dri/swrast_dri.so
No symbol table info available.
#3  0xb1257e67 in ?? () from /usr/lib/i386-linux-gnu/dri/swrast_dri.so
No symbol table info available.
#4  0xb78f1f70 in start_thread (arg=0xad9b2b40) at pthread_create.c:312
        __res = <optimized out>
        pd = 0xad9b2b40
        now = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {-1215283200, -1382339776, 4001536, -1382341592, 
                1751542904, 1075769932}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, 
            data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#5  0xb689470e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129
No locals.

Thread 3 (Thread 0xae1b3b40 (LWP 31678)):
#0  0xb7fdd424 in __kernel_vsyscall ()
No symbol table info available.
#1  0xb78f5d4b in pthread_cond_wait@@GLIBC_2.3.2 ()
    at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_wait.S:187
No locals.
#2  0xb1258cd4 in ?? () from /usr/lib/i386-linux-gnu/dri/swrast_dri.so
No symbol table info available.
#3  0xb1257e67 in ?? () from /usr/lib/i386-linux-gnu/dri/swrast_dri.so
No symbol table info available.
#4  0xb78f1f70 in start_thread (arg=0xae1b3b40) at pthread_create.c:312
        __res = <optimized out>
        pd = 0xae1b3b40
        now = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {-1215283200, -1373947072, 4001536, -1373948888, 
                1749445759, 1075769932}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, 
            data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#5  0xb689470e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129
No locals.

Thread 2 (Thread 0xb0bfdb40 (LWP 31677)):
#0  0xb7fdd424 in __kernel_vsyscall ()
No symbol table info available.
#1  0xb78f5d4b in pthread_cond_wait@@GLIBC_2.3.2 ()
    at ../nptl/sysdeps/unix/sysv/linux/i386/i686/../i486/pthread_cond_wait.S:187
No locals.
#2  0xb1258cd4 in ?? () from /usr/lib/i386-linux-gnu/dri/swrast_dri.so
No symbol table info available.
#3  0xb1257e67 in ?? () from /usr/lib/i386-linux-gnu/dri/swrast_dri.so
No symbol table info available.
#4  0xb78f1f70 in start_thread (arg=0xb0bfdb40) at pthread_create.c:312
        __res = <optimized out>
        pd = 0xb0bfdb40
        now = <optimized out>
        unwind_buf = {cancel_jmp_buf = {{jmp_buf = {-1215283200, -1329603776, 4001536, -1329605592, 
                562457666, 1075769932}, mask_was_saved = 0}}, priv = {pad = {0x0, 0x0, 0x0, 0x0}, 
            data = {prev = 0x0, cleanup = 0x0, canceltype = 0}}}
        not_first_call = <optimized out>
        pagesize_m1 = <optimized out>
        sp = <optimized out>
        freesize = <optimized out>
        __PRETTY_FUNCTION__ = "start_thread"
#5  0xb689470e in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:129
No locals.

Thread 1 (Thread 0xb61c3700 (LWP 31676)):
#0  audio_convert_s16_to_float_SSE2 (out=0x827de88, in=0xb21f1540 <g_rdram+1897472>, samples=320, gain=1)
    at mupen64plus-core/src/plugin/audio_libretro/audio_utils.c:89
        fgain = 4.65661287e-10
        factor = {5.60519386e-45, -6.24618401e-09, 5.07302587e-34, -6.24617691e-09}
        i = 0
#1  0xb1e407d3 in push_audio_samples_via_libretro (user_data=0x0, buffer=0xb21f1540 <g_rdram+1897472>, 
    size=640) at mupen64plus-core/src/plugin/audio_libretro/audio_backend_libretro.c:155
        out = 0x0
        max_frames = 1485
        remain_frames = 0
        i = 640
        ratio = 1.3778666500031245
        data = {data_in = 0x827de88, data_out = 0x8281e90, input_frames = 160, output_frames = 0, 
          ratio = 1.3778666500031245}
        len = 640
        raw_data = 0xb21f1540 <g_rdram+1897472>
        frames = 160
        p = 0xb21f1540 <g_rdram+1897472> ""
        saved_ai_length = 640
        saved_ai_dram = 1897472
#2  0xb1de8bbb in push_audio_samples (backend=0xb2021b14 <g_ai+52>, buffer=0xb21f1540 <g_rdram+1897472>, 
    size=640) at mupen64plus-core/src/api/audio_backend.c:79
No locals.
#3  0xb1e226d2 in do_dma (ai=0xb2021ae0 <g_ai>, dma=0xb2021af8 <g_ai+24>)
    at mupen64plus-core/src/ai/ai_controller.c:101
No locals.
#4  0xb1e22794 in fifo_push (ai=0xb2021ae0 <g_ai>) at mupen64plus-core/src/ai/ai_controller.c:129
        duration = 236655
#5  0xb1e2291b in write_ai_regs (opaque=0xb2021ae0 <g_ai>, address=2756706308, value=640, 
    mask=4294967295) at mupen64plus-core/src/ai/ai_controller.c:184
        ai = 0xb2021ae0 <g_ai>
        reg = 1
#6  0xb1df392d in writew (write_word=0xb1e228a9 <write_ai_regs>, opaque=0xb2021ae0 <g_ai>, 
    address=2756706308, value=640) at mupen64plus-core/src/memory/m64p_memory.c:159
No locals.
#7  0xb1df561d in write_ai () at mupen64plus-core/src/memory/m64p_memory.c:704
No locals.
#8  0xb1e04eed in SW () at mupen64plus-core/src/r4300/interpreter_r4300.def:447
        lsaddr = 2756706308
        lsrtp = 0xb37253a8 <reg+104>
#9  0xb1e25c9e in pc_ops_wrapper () at mupen64plus-core/src/r4300/r4300.c:348
No locals.
#10 0xb1e25d10 in r4300_execute () at mupen64plus-core/src/r4300/r4300.c:363
No locals.
#11 0xb1deaadc in main_run () at mupen64plus-core/src/main/main.c:466
No locals.
#12 0xb1e39701 in EmuThreadFunction () at libretro/libretro.c:369
No locals.
#13 0xb1dcaab0 in co_init () at libretro/libco/x86.c:63
        addr = 0
        base = 0
        size = 0
#14 0x00000000 in ?? ()
No symbol table info available.
kivutar commented 8 years ago

Looks like this is fixed now.

sergiobenrocha2 commented 8 years ago

Seems it's fixed only if you don't load it by the command line

Program received signal SIGSEGV, Segmentation fault.
audio_convert_s16_to_float_SSE2 (out=0x8287918, in=0xb11cb9c0 <g_rdram+1897472>, samples=320, gain=1)
    at mupen64plus-core/src/plugin/audio_libretro/audio_utils.c:89
89     __m128 factor = _mm_set1_ps(fgain);
(gdb) bt 
#0  audio_convert_s16_to_float_SSE2 (out=0x8287918, in=0xb11cb9c0 <g_rdram+1897472>, samples=320, gain=1)
    at mupen64plus-core/src/plugin/audio_libretro/audio_utils.c:89
#1  0xb0e1c370 in push_audio_samples_via_libretro (user_data=0xb0ffbf94 <g_ai+52>, buffer=0xb11cb9c0 <g_rdram+1897472>, size=640)
    at mupen64plus-core/src/plugin/audio_libretro/audio_backend_libretro.c:165
#2  0xb0dfd299 in do_dma (ai=0xb0ffbf60 <g_ai>, dma=0xb0ffbf78 <g_ai+24>) at mupen64plus-core/src/ai/ai_controller.c:106
#3  0xb0dfd35b in fifo_push (ai=0xb0ffbf60 <g_ai>) at mupen64plus-core/src/ai/ai_controller.c:134
#4  0xb0dfd4e2 in write_ai_regs (opaque=0xb0ffbf60 <g_ai>, address=2756706308, value=640, mask=4294967295)
    at mupen64plus-core/src/ai/ai_controller.c:189
#5  0xb0dcf6dc in writew (write_word=0xb0dfd470 <write_ai_regs>, opaque=0xb0ffbf60 <g_ai>, address=2756706308, value=640)
    at mupen64plus-core/src/memory/m64p_memory.c:159
#6  0xb0dd13cc in write_ai () at mupen64plus-core/src/memory/m64p_memory.c:704
#7  0xb0de20c0 in SW () at mupen64plus-core/src/r4300/interpreter.c:488
#8  0xb0e007da in pc_ops_wrapper () at mupen64plus-core/src/r4300/r4300.c:348
#9  0xb0e0084c in r4300_execute () at mupen64plus-core/src/r4300/r4300.c:363
#10 0xb0dc753e in main_run () at mupen64plus-core/src/main/main.c:467
#11 0xb0e16384 in EmuThreadFunction () at libretro/libretro.c:412
#12 0xb0da8f8f in co_init () at libretro-common/libco/x86.c:63
#13 0x00000000 in ?? ()
inactive123 commented 8 years ago

This might be an actual RetroArch problem instead, there still seem to be issues with mupen64plus or any libretro GL core when launching it directly from the commandline. Maybe alert @Themaister to it.