libretro / smsplus-gx

Improved port of SMSPlus-GX by gameblabla for libretro
12 stars 18 forks source link

Sound-related segfault when starting "Wanted" #32

Closed Sanaki closed 2 years ago

Sanaki commented 2 years ago

Haven't managed to reproduce the issue with a small selection of other games, but since it appears sound-based from the backtrace, I assume there are others that would trigger it as well.

RetroArch version libretro/RetroArch@cda66d09c3 SMS Plus GX version 3f1ffede55bcfe0168caa484a00bf041ab591abf

Full gdb backtrace ```gdb Thread 1 "retroarch" received signal SIGSEGV, Segmentation fault. 0x00007fffe5e24818 in SN76489_Update () from /home/ccrowley/src/libretro-super/libretro-smsplus/smsplus_libretro.so (gdb) thread apply all bt Thread 11 (Thread 0x7fffdbfff700 (LWP 9955) "retroarch"): #0 0x00007ffff46d8065 in futex_abstimed_wait_cancelable (private=, abstime=0x7fffdbffeda0, expected=0, futex_word=0x555558db53e8) at ../sysdeps/unix/sysv/linux/futex-internal.h:205 #1 __pthread_cond_wait_common (abstime=0x7fffdbffeda0, mutex=0x555556a65d20, cond=0x555558db53c0) at pthread_cond_wait.c:539 #2 __pthread_cond_timedwait (cond=0x555558db53c0, mutex=0x555556a65d20, abstime=0x7fffdbffeda0) at pthread_cond_wait.c:667 #3 0x00005555559f5b72 in scond_wait_timeout (cond=0x555558db53c0, lock=0x555556a65d20, timeout_us=10000000) at libretro-common/rthreads/rthreads.c:900 #4 0x000055555568491e in autosave_thread (data=0x555558db5460) at tasks/task_save.c:234 #5 0x00005555559f5606 in thread_wrap (data_=0x555556a71170) at libretro-common/rthreads/rthreads.c:143 #6 0x00007ffff46d16db in start_thread (arg=0x7fffdbfff700) at pthread_create.c:463 #7 0x00007fffef29d71f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Thread 10 (Thread 0x7fffe29c9700 (LWP 9942) "threaded-ml"): #0 0x00007ffff46db474 in __libc_read (fd=0, buf=0x7fffe29c8bde, nbytes=10) at ../sysdeps/unix/sysv/linux/read.c:27 #1 0x00007fffed3d70f1 in pa_read () from /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-11.1.so #2 0x00007ffff4e05a2e in pa_mainloop_prepare () from /usr/lib/x86_64-linux-gnu/libpulse.so.0 #3 0x00007ffff4e064a0 in pa_mainloop_iterate () from /usr/lib/x86_64-linux-gnu/libpulse.so.0 #4 0x00007ffff4e06560 in pa_mainloop_run () from /usr/lib/x86_64-linux-gnu/libpulse.so.0 #5 0x00007ffff4e143c9 in ?? () from /usr/lib/x86_64-linux-gnu/libpulse.so.0 #6 0x00007fffed406468 in ?? () from /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-11.1.so #7 0x00007ffff46d16db in start_thread (arg=0x7fffe29c9700) at pthread_create.c:463 #8 0x00007fffef29d71f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Thread 9 (Thread 0x7fffe109e700 (LWP 9916) "[vkrt] Analysis"): #0 0x00007ffff46d8065 in futex_abstimed_wait_cancelable (private=, abstime=0x7fffe109dd50, expected=0, futex_word=0x7fffdc000d2c) at ../sysdeps/unix/sysv/linux/futex-internal.h:205 #1 __pthread_cond_wait_common (abstime=0x7fffe109dd50, mutex=0x5555568dc960, cond=0x7fffdc000d00) at pthread_cond_wait.c:539 #2 __pthread_cond_timedwait (cond=0x7fffdc000d00, mutex=0x5555568dc960, abstime=0x7fffe109dd50) at pthread_cond_wait.c:667 #3 0x00007fffd2b9efd2 in ?? () from /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.495.44 #4 0x00007fffd3015a45 in ?? () from /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.495.44 #5 0x00007fffd2ba1288 in ?? () from /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.495.44 #6 0x00007ffff46d16db in start_thread (arg=0x7fffe109e700) at pthread_create.c:463 #7 0x00007fffef29d71f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Thread 8 (Thread 0x7fffdacd9700 (LWP 9915) "retroarch"): #0 0x00007ffff46d8065 in futex_abstimed_wait_cancelable (private=, abstime=0x7fffdacd8d40, expected=0, futex_word=0x7fffcc00be38) at ../sysdeps/unix/sysv/linux/futex-internal.h:205 #1 __pthread_cond_wait_common (abstime=0x7fffdacd8d40, mutex=0x55555723f290, cond=0x7fffcc00be10) at pthread_cond_wait.c:539 #2 __pthread_cond_timedwait (cond=0x7fffcc00be10, mutex=0x55555723f290, abstime=0x7fffdacd8d40) at pthread_cond_wait.c:667 #3 0x00007fffd2b9efd2 in ?? () from /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.495.44 #4 0x00007fffd2ffec64 in ?? () from /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.495.44 #5 0x00007fffd2ba1288 in ?? () from /usr/lib/x86_64-linux-gnu/libnvidia-glcore.so.495.44 #6 0x00007ffff46d16db in start_thread (arg=0x7fffdacd9700) at pthread_create.c:463 #7 0x00007fffef29d71f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Thread 7 (Thread 0x7fffe6b5e700 (LWP 9912) "retroarch"): #0 0x00007fffef290cb9 in __GI___poll (fds=fds@entry=0x7fffe6b5bdb8, nfds=nfds@entry=1, timeout=5000, timeout@entry=) at ../sysdeps/unix/sysv/linux/poll.c:29 #1 0x00007fffe6d7df49 in send_dg (ansp2_malloced=0x7fffe6b5d348, resplen2=0x7fffe6b5d344, anssizp2=0x7fffe6b5d340, ansp2=0x7fffe6b5d358, anscp=0x7fffe6b5d350, gotsomewhere=, v_circuit=, ns=0, terrno=0x7fffe6b5bd88, anssizp=0x7fffe6b5beb0, ansp=0x7fffe6b5bd78, buflen2=39, buf2=0x7fffe6b5bf08 "\030\345\001", buflen=39, buf=0x7fffe6b5bee0 "\004\335\001", statp=) at res_send.c:1115 #2 __res_context_send (ctx=ctx@entry=0x7fffb8074590, buf=buf@entry=0x7fffe6b5bee0 "\004\335\001", buflen=buflen@entry=39, buf2=buf2@entry=0x7fffe6b5bf08 "\030\345\001", buflen2=buflen2@entry=39, ans=, ans@entry=0x7fffe6b5cb00 "0ص\340\377\177", anssiz=, ansp=, ansp2=, nansp2=, resplen2=, ansp2_malloced=) at res_send.c:522 #3 0x00007fffe6d7b4d1 in __GI___res_context_query (ctx=ctx@entry=0x7fffb8074590, name=name@entry=0x555557c47648 "retroachievements.org", class=class@entry=1, type=type@entry=439963904, answer=answer@entry=0x7fffe6b5cb00 "0ص\340\377\177", anslen=anslen@entry=2048, answerp=0x7fffe6b5d350, answerp2=0x7fffe6b5d358, nanswerp2=0x7fffe6b5d340, resplen2=0x7fffe6b5d344, answerp2_malloced=0x7fffe6b5d348) at res_query.c:216 #4 0x00007fffe6d7c28d in __res_context_querydomain (domain=0x0, answerp2_malloced=0x7fffe6b5d348, resplen2=0x7fffe6b5d344, nanswerp2=0x7fffe6b5d340, answerp2=0x7fffe6b5d358, answerp=0x7fffe6b5d350, anslen=2048, answer=0x7fffe6b5cb00 "0ص\340\377\177", type=439963904, class=1, name=0x555557c47648 "retroachievements.org", ctx=0x7fffb8074590) at res_query.c:601 #5 __GI___res_context_search (ctx=ctx@entry=0x7fffb8074590, name=name@entry=0x555557c47648 "retroachievements.org", class=class@entry=1, type=type@entry=439963904, answer=answer@entry=0x7fffe6b5cb00 "0ص\340\377\177", anslen=anslen@entry=2048, answerp=0x7fffe6b5d350, answerp2=0x7fffe6b5d358, nanswerp2=0x7fffe6b5d340, resplen2=0x7fffe6b5d344, answerp2_malloced=0x7fffe6b5d348) at res_query.c:370 #6 0x00007fffd8944b56 in _nss_dns_gethostbyname4_r (name=name@entry=0x555557c47648 "retroachievements.org", pat=pat@entry=0x7fffe6b5d4d8, buffer=0x7fffe6b5d760 "", buflen=1024, errnop=errnop@entry=0x7fffe6b5e628, herrnop=herrnop@entry=0x7fffe6b5e68c, ttlp=0x0) at nss_dns/dns-host.c:351 #7 0x00007fffef281e15 in gaih_inet (name=name@entry=0x555557c47648 "retroachievements.org", service=, req=req@entry=0x7fffe6b5dc20, pai=pai@entry=0x7fffe6b5d6e8, naddrs=naddrs@entry=0x7fffe6b5d6e4, tmpbuf=tmpbuf@entry=0x7fffe6b5d750) at ../sysdeps/posix/getaddrinfo.c:786 #8 0x00007fffef283da4 in __GI_getaddrinfo (name=, service=, hints=0x7fffe6b5dc20, pai=0x7fffe6b5dc98) at ../sysdeps/posix/getaddrinfo.c:2300 #9 0x0000555555e35989 in getaddrinfo_retro (node=0x555557c47648 "retroachievements.org", service=0x7fffe6b5dc50 "443", hints=0x7fffe6b5dc20, res=0x7fffe6b5dc98) at libretro-common/net/net_compat.c:253 #10 0x0000555555e37db9 in socket_init (address=0x7fffe6b5dc98, port=443, server=0x555557c47648 "retroachievements.org", type=SOCKET_TYPE_STREAM) at libretro-common/net/net_socket.c:63 #11 0x0000555555e361f9 in net_http_new_socket (conn=0x555556a69ff0) at libretro-common/net/net_http.c:420 #12 0x0000555555e36b32 in net_http_new (conn=0x555556a69ff0) at libretro-common/net/net_http.c:714 #13 0x0000555555e3bb0c in cb_http_conn_default (data_=0x7fffb8071ce0, len=0) at tasks/task_http.c:97 #14 0x0000555555e3baa0 in task_http_conn_iterate_transfer_parse (http=0x7fffb8071ce0) at tasks/task_http.c:77 #15 0x0000555555e3bd28 in task_http_transfer_handler (task=0x55555719ab20) at tasks/task_http.c:154 #16 0x000055555567c5f8 in threaded_worker (userdata=0x0) at libretro-common/queues/task_queue.c:508 #17 0x00005555559f5606 in thread_wrap (data_=0x5555576e5e90) at libretro-common/rthreads/rthreads.c:143 #18 0x00007ffff46d16db in start_thread (arg=0x7fffe6b5e700) at pthread_create.c:463 #19 0x00007fffef29d71f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Thread 6 (Thread 0x7fffd9b5e700 (LWP 9838) "retroarch"): #0 0x00007ffff46d8065 in futex_abstimed_wait_cancelable (private=, abstime=0x7fffd9b5dc30, expected=0, futex_word=0x555556f8adb8) at ../sysdeps/unix/sysv/linux/futex-internal.h:205 #1 __pthread_cond_wait_common (abstime=0x7fffd9b5dc30, mutex=0x555556f8ad68, cond=0x555556f8ad90) at pthread_cond_wait.c:539 #2 __pthread_cond_timedwait (cond=0x555556f8ad90, mutex=0x555556f8ad68, abstime=0x7fffd9b5dc30) at pthread_cond_wait.c:667 #3 0x0000555555e7aec1 in __gthread_cond_timedwait (__cond=0x555556f8ad90, __mutex=0x555556f8ad68, __abs_timeout=0x7fffd9b5dc30) at /usr/include/x86_64-linux-gnu/c++/11/bits/gthr-default.h:872 #4 0x0000555555e7b428 in std::__condvar::wait_until (this=0x555556f8ad90, __m=..., __abs_time=...) at /usr/include/c++/11/bits/std_mutex.h:162 #5 0x0000555555e7d13c in std::condition_variable::__wait_until_impl > > (this=0x555556f8ad90, __lock=..., __atime=...) at /usr/include/c++/11/condition_variable:222 #6 0x0000555555e7c8d2 in std::condition_variable::wait_until > > (this=0x555556f8ad90, __lock=..., __atime=...) at /usr/include/c++/11/condition_variable:135 #7 0x0000555555e7bbca in std::condition_variable::wait_for > (this=0x555556f8ad90, __lock=..., __rtime=...) at /usr/include/c++/11/condition_variable:163 #8 0x0000555555e7b63f in IoThreadHolder::Start()::{lambda()#1}::operator()() const (__closure=0x555557c0ca58) at deps/discord-rpc/src/discord_rpc.cpp:102 #9 0x0000555555e7dbd0 in std::__invoke_impl(std::__invoke_other, IoThreadHolder::Start()::{lambda()#1}&&) (__f=...) at /usr/include/c++/11/bits/invoke.h:61 #10 0x0000555555e7db85 in std::__invoke(IoThreadHolder::Start()::{lambda()#1}&&) (__fn=...) at /usr/include/c++/11/bits/invoke.h:96 #11 0x0000555555e7db32 in std::thread::_Invoker >::_M_invoke<0ul>(std::_Index_tuple<0ul>) (this=0x555557c0ca58) at /usr/include/c++/11/bits/std_thread.h:253 #12 0x0000555555e7db06 in std::thread::_Invoker >::operator()() (this=0x555557c0ca58) at /usr/include/c++/11/bits/std_thread.h:260 #13 0x0000555555e7daea in std::thread::_State_impl > >::_M_run() (this=0x555557c0ca50) at /usr/include/c++/11/bits/std_thread.h:211 #14 0x00007fffefdfb4c0 in ?? () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 #15 0x00007ffff46d16db in start_thread (arg=0x7fffd9b5e700) at pthread_create.c:463 #16 0x00007fffef29d71f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Thread 1 (Thread 0x7ffff7e00800 (LWP 9804) "retroarch"): #0 0x00007fffe5e24818 in SN76489_Update () from /home/ccrowley/src/libretro-super/libretro-smsplus/smsplus_libretro.so #1 0x00007fffe5e3eaec in SMSPLUS_sound_update () from /home/ccrowley/src/libretro-super/libretro-smsplus/smsplus_libretro.so #2 0x00007fffe5e2a275 in system_frame () from /home/ccrowley/src/libretro-super/libretro-smsplus/smsplus_libretro.so #3 0x00007fffe5e451f1 in retro_run () from /home/ccrowley/src/libretro-super/libretro-smsplus/smsplus_libretro.so #4 0x0000555555660efd in core_run () at runloop.c:8227 #5 0x000055555565fc22 in runloop_iterate () at runloop.c:7624 #6 0x00005555556498c2 in rarch_main (argc=1, argv=0x7fffffffd808, data=0x0) at retroarch.c:3824 #7 0x000055555584b27d in main (argc=1, argv=0x7fffffffd808) at ui/drivers/ui_qt.cpp:4315 ```
gameblabla commented 2 years ago

I did not get a sound crash issue on my "upstream" version but it would crash on an earlier revision of it. They probably didn't merge some of the sound-related changes that i've done purposely to avoid potential crashes like this one. In addition to that, the game will also refuse to work on a Master System with an FM sound unit plugged in. This was not documented anywhere else, making me wonder if this also happens on real hardware as well.

See my changes upstream here : https://github.com/gameblabla/sms_sdl/commit/ca69b71907337c96674d78254a782c0c6088304b

negativeExponent commented 2 years ago

'merged latest updates from upstream'

Sanaki commented 2 years ago

Confirmed fixed. Thanks!