Loading save state crashes emulator

Issue #144 resolved
Former user created an issue

Original [issue 144](https://code.google.com/p/genplus-gx/issues/detail?id=144) created by LeonKennedy_007@yahoo.de on 2010-12-11T22:49:24.000Z:

What steps will reproduce the problem? 1. Load a random game (I tried Mortal Kombat, Mega Bomberman Sonic) 2. Load a save state for that game. If you don't have one, create it and load it.

What is the expected output? What do you see instead? The emulator will crash and show a code dump.

What version of the emulator are you using (official, SVN revision,...)? genplus-gx-1.4.1. - Gamecube

Please provide any additional information below (Video settings, Console region,...) Everything seemed to work fine in the beginning. I played Splatterhouse 2 (with game genie codes) and before reaching a certain boss, I saved my state and kept reloading it after dying. Then for some reason the emulator crashed. Since then I am not able to load a save state.

Comments (48)

  1. Former user Account Deleted
    • changed status to open

    Comment # 1 originally posted by ekeeke31 on 2010-12-12T00:07:18.000Z:

    I need picture of the crash as it could be anything: the program cannot just "stop" loading state like that, the code always do the same thing so if it worked, the only possibilities are either the SD card where savestates are written/loaded is corrupt, or the crash is related to something else that happened at the same time...

  2. Former user Account Deleted

    Comment # 3 originally posted by ekeeke31 on 2010-12-13T12:12:32.000Z:

    I cannot reproduce this issue, saving & loading state files works fine for me on gamecube.

    Unless you provide me additional informations I requested (device info, core dump screen shot, exact way used to reproduce the issue, etc), I will have to close it.

  3. Former user Account Deleted

    Comment # 4 originally posted by LeonKennedy_007@yahoo.de on 2010-12-13T14:46:16.000Z:

    PAL Gamecube qoob Pro (sw1.3c) SD Gecko with Intenso micro SD card (2GB)

    Core dump screenshot is coming up in an hour or so. I have to find a camera to take a picture of the tv screen.

    I was playing Splatterhouse 2 (with the game genie code "AX3A-AA2N" applied) and came to a point where I had to load a save state every 3 to 4 minutes. About the 15th time I tried to load, the emulator crashed. Since then it is not possible for me to load a save state. I tried loading a save state I created before the crash (Sonic) and creating a new one and loading that one (Mortal Kombat). I get a code dump every time.

    As I said, screenshot is coming in a few moments...

  4. Former user Account Deleted

    Comment # 5 originally posted by ekeeke31 on 2010-12-13T15:35:10.000Z:

    Please also attach those 3 save state files (Splatter House 2, Sonic & Mortal Kombat) here.

  5. Former user Account Deleted

    Comment # 6 originally posted by LeonKennedy_007@yahoo.de on 2010-12-13T16:08:50.000Z:

    Here you go, all of the requested files...

  6. Former user Account Deleted

    Comment # 8 originally posted by ekeeke31 on 2010-12-13T19:28:56.000Z:

    Ok, I think I found the cause of the crash. It happens during the load of VDP state, while overwriting VDP registers. For a stupid reason, it causes a line of display to be redrawn but since the NTSC filter has not been initialized yet (it's initialized when you leave the menu), the NTSC filter rendering function crashes.

    I bet save state worked fine until you activated the NTSC filter, disabling it back should fix the issue until next version comes out.

  7. Former user Account Deleted

    Comment # 9 originally posted by ekeeke31 on 2010-12-13T19:40:44.000Z:

    Please test the attached dol and tell me if the issue is fixed (even with NTSC filter being enabled)

  8. Former user Account Deleted

    Comment # 10 originally posted by LeonKennedy_007@yahoo.de on 2010-12-13T21:05:43.000Z:

    Awesome! It seems you were totally right. I turned off the NTSC filter and my save states started to work again.

    The issue is fixed with the new dol! NTSC filters are working now with save states.

    Only my Splatter House 2 save state seems to be broken. It just freezes the emulator.

  9. Former user Account Deleted

    Comment # 11 originally posted by LeonKennedy_007@yahoo.de on 2010-12-13T22:31:50.000Z:

    OK, it's not just the NTSC filter. Every now and then a save state gets corrupted. I played Battletoads and saved after every checkpoint in the surfing stage. Upon loading the most recent save state, the game worked for 1 second and then just froze accompanied by a humming noise.

    It is the same issue as with Splatter House 2. Seems saving often results in a corrupted file every now and then. The save state for Battletoads is attached.

  10. Former user Account Deleted

    Comment # 13 originally posted by ekeeke31 on 2010-12-14T08:54:32.000Z:

    Ok, thanks to you, I spotted another bug in state loading.

    For the record, Z80 interrupt callback was saved as a function pointer and restored from the save state file which is not stable at all. Indeed, function addresses can potentially change every time you modify & recompile the application (which I did with the test version above) so the Z80 interrupt callback was actually pointing to code that had nothing to do with it, resulting in a crash.

    Please tell me if this new test version fixes save state loading (it did for me)

  11. Former user Account Deleted

    Comment # 14 originally posted by LeonKennedy_007@yahoo.de on 2010-12-14T17:37:19.000Z:

    No, it doesn't work for me. I get a code dump every time I try to load a (new or old) save state.

  12. Former user Account Deleted

    Comment # 15 originally posted by ekeeke31 on 2010-12-14T18:16:40.000Z:

    Oops, I forgot to report the NTSC filter fix in this dol. Try with NTSC filter disabled, I will post a new dol later.

  13. Former user Account Deleted

    Comment # 17 originally posted by LeonKennedy_007@yahoo.de on 2010-12-14T19:44:25.000Z:

    I have been playing Battletoads for the last hour or so, with excessive saving and loading. Aproximately the 30th save state I made got corrupted. Again it froze the emulator leaving me with a humming sound.

    Guess this problem has nothing to do with the loading process but with saving itself.

    I will be out of town for the rest of the week, so unfortunately I won't be able to check out the progress you may make.

  14. Former user Account Deleted

    Comment # 18 originally posted by ekeeke31 on 2010-12-14T19:51:48.000Z:

    I don't think so, I think it's the way they are loaded (you confirm that the freeze occurs only when loading, right ?). Here are fixed dols including the 2 last fixes.

    If you think you have a corrupted save state, please upload it so I can have a look and always report which version you were using (official or last beta)

  15. Former user Account Deleted

    Comment # 19 originally posted by ekeeke31 on 2010-12-14T22:51:23.000Z:

    I reproduced the issue. The bug happens with state files that were saved with High-Quality FM option enabled, if you load them with this option disabled, the emulator freeze (I have yet to find why but I have some ideas).

    Can you confirm that you changed this option or deleted your config.ini file ? Try reloading the "corrupted" state files with HQ FM enabled in audio settings.

  16. Former user Account Deleted

    Comment # 20 originally posted by ekeeke31 on 2010-12-14T23:09:23.000Z:

    Here are new test builds which appeared to fix the "freeze" issue on my side, no matter of the state of High-Quality FM option. There was a bug when restoring FM chip cycle count value from state file, the value saved in HQ mode could lead to unpredictable behavior in non-HQ mode.

  17. Former user Account Deleted

    Comment # 21 originally posted by LeonKennedy_007@yahoo.de on 2010-12-19T23:16:46.000Z:

    The new DOL seems to work fine. I have played some games for a couple of hours and saved and loaded states like mad. No issues what so ever...

    Even the savestates I thought were corrupted worked fine. That's strange because I only changed the HQ FM options only at the beginning and never touched them again, certainly not while saving and loading states.

  18. Former user Account Deleted

    Comment # 24 originally posted by noddykev@hotmail.co.uk on 2011-01-09T06:01:37.000Z:

    I still have a few save states that are crashing namely Virtua Racing and Castle of Illusion, i'll upload them later today.

  19. Former user Account Deleted

    Comment # 26 originally posted by ekeeke31 on 2011-01-11T14:07:20.000Z:

    Savestate are not game dependent (except Virtua Racing but it loaded/saved fine last time I tested... it was not working in earlier versions though, before I improved the savesate format so be sure to use files saved from the current version).

    All games mentionned here save & load fine for me (I didn't try your files though, will try when I could access to my equipment)

    Each previous crash were caused by incompatibilities when loading a state file that was saved with different emulator settings so please give me you current settings (system, audio & video) and try remembering if you changed some of them.

    Also make sure those files are not from older versions. Have you try to test tghose games by saving a state file, reset the emulator / reload the game, then load the same state file ?

  20. Former user Account Deleted

    Comment # 27 originally posted by noddykev@hotmail.co.uk on 2011-01-12T03:18:08.000Z:

    Ayrton Sennas Super Monaco GP II (U) [a1].gp0 = rev 502 I'm not sure what revisions the other ones where saved with but there dated eatlier. All games save / load fine with latest version. I'm still getting random crashes in gameplay with Castle of Illusion and Sonic games though which normally happens when backtracking. The only thing i've changed throughout versions is the button config.

  21. Former user Account Deleted

    Comment # 28 originally posted by ekeeke31 on 2011-01-12T08:43:22.000Z:

    What do you mean, by "All games save / load fine with latest version" ? I don't understand what issue you are having with those files then ?

    You should use the DOL I posted above which fix savestate issues, to load AND save new files, old files are NOT reliable.

    Also, what do you exactly mean by "random crash in gameplay" and "backtracking" ? how is it related to savestates ? again, there is nothing specific to "castle of illusion and sonic games" , and I need screenshot of the exception screen, I can't just guess what it is as those games work, save & load perfectly here for me.

  22. Former user Account Deleted

    Comment # 29 originally posted by noddykev@hotmail.co.uk on 2011-01-12T09:10:00.000Z:

    I meant fresh saves created with latest build work fine not my old saves from previous revisions that I uploaded.

    I don't get any exeception screen it just freezes up in-game randomly where the chracter is no longer movable and nothing happens on screen, sorry I can't be more specific, it's not the saves that create the problem as it happens without saving too.

    Also every newly created save is fragmented.

  23. Former user Account Deleted

    Comment # 30 originally posted by ekeeke31 on 2011-01-12T09:39:00.000Z:

    As I said earlier, state files saved with previous versions can be buggy, this is pretty much expected (for example, in 1.4.0, Virtua racing was incompletely saved, resulting in crash when loaded... loading this state with the fixed emulator won't solve the issue since info is originally missing in the file. The same thing can happen with state files saved with 1.4.1 were additional infos were saved but some of them incorrectly, which is fixed for next version i.e in the version posted above)

    Freezes might me related to something else, I never experimented these on Gamecube though and therefore it could be very difficult to fix. I am not even sure it is an emulation issue and not an hardware issue . Are you able to get back to the menu when this happen ? Does the reset button still reset the game ? What happens with sound ? This woudl also help if you could get back to 1.4.0 and test if those random freeze already happened.

    Lastly, I don't understand what you mean by "fragmented" saves ? How do I see that ? Files are created using an external library anyway, the program just call open/write/close functions like on any other platform so I hardly what I could do wrong ghere.

  24. Former user Account Deleted

    Comment # 31 originally posted by ekeeke31 on 2011-01-12T09:44:28.000Z:

    Before I forget, state files created with unofficial builds (like rev 502) are subject to crash, this is expected. Remember that revisions between official builds are BETA and I warned many times about the fact the code is constantly evolving at this time, meaning that files saved with a revision might not be compatible anymore in the next revision.

  25. Former user Account Deleted

    Comment # 32 originally posted by noddykev@hotmail.co.uk on 2011-01-13T13:16:45.000Z:

    No i'm not not able to get back to the menu, buttons have no effect and I hear no sound, not enough memory free possibly taken up by previsouly loaded game? and yes they happened with v1.4.0 also.

    Fragmentation could be possibly be down to SDML's mounting of the SD card, when I check my sd card in Auslogics Disk Defrag though every new save I create it's always fragmented, I'll try using sdload dol loader instead see if I get the same result.

  26. Former user Account Deleted

    Comment # 33 originally posted by noddykev@hotmail.co.uk on 2011-01-13T13:32:09.000Z:

    Same result with SD-Load :-(

  27. Former user Account Deleted

    Comment # 34 originally posted by ekeeke31 on 2011-01-13T15:00:08.000Z:

    Why do you care about "fragmented" files indicated by a PC tool ? It's the way the library is writing to SD card and is probably perfectly normal. At least, there is absolutely nothing we can do against that and it has probably been like this since the beginning and for everybody, never damaged any SD card afaik... To sum up, it's not an issue and nothing you should worry about as long as files are readable.

    Back to your "freeze" issue, I doubt it could be another memory leak (also, memory for games is allocated for once when the emulator starts, with the maximal ROM size) unless you tell me it usually happens when you switch a lot between game and menu. Even in that case, it would not crash randomly while you are playing, memory don't get allocated or freed during gameplay so it's most likely an exception occuring (but without the normal exception screen) for an unknown reason or an hardware failure on your side (I think I've heard that CPU or GPU could freeze when overheating, especially if ventilation circuitry is damaged).

    Since I cannot reproduce this on my side and nobody else has reporting such crash so far, I'm afraid it's the later case.

  28. Former user Account Deleted

    Comment # 35 originally posted by noddykev@hotmail.co.uk on 2011-01-13T22:15:58.000Z:

    I don't care about it damagaing my sd card as I know it probably won't, I just think it's bad practice for the emulator to be saving / reading fragmented files it doesn't happpen on the saved config file so it shouldn't happen for saves.

  29. Former user Account Deleted

    Comment # 36 originally posted by ekeeke31 on 2011-01-14T09:03:02.000Z:

    config file is way much smaller than save files, hence why it is not fragmented.

    I guess it depends on the sector size of your SD card but anyway, as I said, it's tied to libfat implementation (i.e it's the same for ALL homebrew) and there is nothing I can do against that.

    Bad practice or not, the emulator does not care (and does not even know) about fragmented chunks, it just uses classic open/read/write/close API, what happen at lower hardware level is and should remain transparent and it does not affect emulator behavior.

  30. Former user Account Deleted

    Comment # 37 originally posted by bennayboy on 2011-01-14T21:44:38.000Z:

    I have the same problem with the metal sonic3 & knuckles REV01 hack.

  31. Former user Account Deleted

    Comment # 38 originally posted by ekeeke31 on 2011-01-14T22:34:52.000Z:

    which problem and with which version of the emulator ? The beta version that fixes savestate issues is here in comment comment 20\., give it a try.

  32. Former user Account Deleted

    Comment # 39 originally posted by bennayboy on 2011-01-14T23:45:41.000Z:

    YESSSSS!!!!!! It loaded the save-state fine after I pasted C20's download via wiixplorer transfer method (USB to SD). THANK YOU!

  33. Former user Account Deleted

    Comment # 40 originally posted by noddykev@hotmail.co.uk on 2011-01-19T00:01:47.000Z:

    Having lots of fragmented files on the SD card causes problems for the loading of other .dol programs stored on the same SD card, i've noticed this before with SD-boot and all the various emulators where they either BlSoD or the R gets switched with B in the RGB colours.

  34. Former user Account Deleted

    Comment # 41 originally posted by ekeeke31 on 2011-01-19T08:02:51.000Z:

    I've already got BSOD too and it's definitively caused by the DOL file not being written properly (copying it back and properly disconnecting the SD adapter from PC generally fixes this), there is absolutely no proof that this is caused by fragmented files on SD, this is just a guess you made because you were looking for some explanation and noticed files were fragmented but to me, it does not make many sense, the problem is with the .dol file, not with .srm or .gpz files.

    Video issues are hardware-related I'm sorry, no way reading stuff from SD and loading DOL into memory could switch R & B channels. You sometime got frozen green screen issues but it's the same as BSOD, it's the default screen color when video is not initialized by the program (because it crashed).

  35. Former user Account Deleted

    Comment # 42 originally posted by bennayboy on 2011-01-19T17:17:02.000Z:

    Still does not load correctly,I loaded the save-state a second time and some sound went missing so I turned high quality FM off,loaded it again,sound worked fine,and in a special stage when I get the emerald,it crashes (no dump).

  36. Former user Account Deleted

    Comment # 43 originally posted by noddykev@hotmail.co.uk on 2011-01-19T20:06:34.000Z:

    Don't treat me as stupid, I know how write files & from a sd card as well properly removing the card reader from the pc, I'm not just throwing it out as a explanation, it's fact. If a dol file wasn't properly written to the sd card in the first place a defragmentation of over files on the same sd card wouldn't make a difference anyway.

  37. Former user Account Deleted

    Comment # 44 originally posted by ekeeke31 on 2011-01-19T22:00:03.000Z:

    I treat nobody as stupid, I'm trying to explain you that it's impossible to prove that fragmented files can have any effect on SD Load: just because it worked after you defragmented your SD could be a coincidence, now matter how much you are convinced. It just indicates that SDLOAD have some issue with the SD file structure.

    As I told you, I got similar issues when trying to load dols and I fixed it by simply deleting the dol and copying it back again. There were no .srm or .gpz files on that card, only files copied from my PC (rom files) and the default ini file. Sometime it does not happen for a while then it happens without any reason. See, it could be anything, there is no way to tell what cause that issue.

    What I'm sure though is that I'm not doing anything special to write files on SD, the code did not changed for a while and I think I'm using the fwrite function correctly, the only thing that could have an impact would be the libfat library and a compatibility issue with SD Load low-level functions (never had such problem on Wii for example) so this is out of the scope of this emulator.

    Now we could discuss this endlessly but I'm afraid there is nothing I can do and I think I already took enough time to address your concerns.

  38. Former user Account Deleted

    Comment # 45 originally posted by ekeeke31 on 2011-01-19T22:19:23.000Z:

    @ bennayboy

    your issue seems different than previous ones. If it does not crash when you load the state file but later during the game, it's something else. Again, this could be lot of things (bugged ROM hack, HBC network/reload bug, hardware issue, ...) and not necessarily related to the state file.

    About the sound missing, does it happen every time you load that state file with HQ FM enabled ? Which version of the emulator did you use to make that state file ?

    Attaching the problematic file would also help.

  39. Former user Account Deleted

    Comment # 46 originally posted by bennayboy on 2011-01-21T03:25:32.000Z:

    Throughout everything,it is probably not the save-state itself but the method of loading save-states must have some problems.

    My save-state was from the latest 1.4.1 commit mentioned before comment 20's test file.

    I saved over it using c20's update after completing the fifth blue sphere special stage in hydrocity zone act 1 in case it wanted to crash again.

  40. Former user Account Deleted

    Comment # 47 originally posted by ekeeke31 on 2011-01-21T08:58:30.000Z:

    The method is fine, it would crash directly when you load the state file otherwise. If the file was saved with an older version, it could explain why sound went (FM state is now saved/retsored differntly) but still, it does not happen for me with old state files I tested.

    AGAIN, can you upload the state file so I can test it ?

  41. Former user Account Deleted

    Comment # 48 originally posted by bennayboy on 2011-01-21T20:04:49.000Z:

    My upload sucks and to make matters worse my internet is acting up as well.

  42. Former user Account Deleted

    Comment # 49 originally posted by bennayboy on 2011-01-22T05:22:25.000Z:

    After I tried again it actually was uploading but then it failed on an error page when it hit 100%.

    So its not my upload speed after all,I have charter internet that goes 300kb-1400kb-max2000kb download,but I do not know my upload speed (pretty good).

  43. Log in to comment