libretro / parallel-n64

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

Seg Faults on Exit #636

Open mrfixit2001 opened 4 years ago

mrfixit2001 commented 4 years ago

I am seeing intermittent segmentation faults when I exit the core. About 80% of the time when I exit the core this happens, and maybe 20% or less it will exit successfully. This issue results in the configuration changes made not being saved. Here is verbose output of the issue: https://pastebin.com/AtEv6Jmu

MastaG commented 4 years ago

Same here.. It only seems to happen on ARM.

If you look here https://github.com/libretro/parallel-n64/issues/592 you can see it was bisected to a specific commit.

I hope this will be fixed soon, because it's a very nice emulator otherwise.

mrfixit2001 commented 4 years ago

@MastaG that was exactly what I needed to know! I've reviewed that commit and identified the bug. The issue is the dev split up the r4300_execute command and is trying to use the "stop" variable in a function where it's not defined. This will resolve. If the dev wants to add additional logic for the stop variable he will have to rework this, but it's not necessary.

MRFIXIT: Fix a segfault due to trying to use an undefined variable
--- a/mupen64plus-core/src/r4300/r4300.c
+++ b/mupen64plus-core/src/r4300/r4300.c
@@ -144,27 +144,22 @@
     {
 #if NEW_DYNAREC
         new_dyna_start();
-        if (stop)
-            new_dynarec_cleanup();
+        new_dynarec_cleanup();
 #else
         dyna_start(dynarec_setup_code);
-        if (stop)
-            PC++;
+        PC++;
 #endif
-        if (stop)
-            free_blocks();
+        free_blocks();
     }
 #endif
     else /* if (r4300emu == CORE_INTERPRETER) */
     {
         r4300_step();

-        if (stop)
-            free_blocks();
+        free_blocks();
     }

-    if (stop)
-        DebugMessage(M64MSG_INFO, "R4300 emulator finished.");
+    DebugMessage(M64MSG_INFO, "R4300 emulator finished.");
 }

 int retro_stop_stepping(void);
MastaG commented 4 years ago

Thank you mrfixit2001 ! I'll try it asap and report back here :-)

MastaG commented 4 years ago

Well mrixit2001, you're a legend and a true Mr Fix IT ;-)

It does not segfault any longer!

Please send in a PR :+1:

MastaG commented 4 years ago

Well I was a bit too soon I guess.. it can successfully stop, but when doing a restart it still segfault here... but great progress nevertheless :)

EDIT: Well it freezes and sometimes segfaults, especially after changing the plugins and then restarting the emulator.

EDIT2: Nevermind, its OK :+1: just commit :)

mrfixit2001 commented 4 years ago

https://github.com/libretro/parallel-n64/pull/637