TASEmulators / BizHawk

BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.
http://tasvideos.org/BizHawk.html
Other
2.18k stars 382 forks source link

Fatal error: SEHException in BizHawk 2.5.2 when using BSNES #2395

Closed Morilli closed 4 years ago

Morilli commented 4 years ago

Summary

Trying to seek around in a .bk2 file made from an earlier version of BizHawk (precisely 2.4.0) crashes bizhawk consistently with varying messages depending on what you do exactly, I've gotten at least 3 different variants so far.

Repro

Open this .bk2 file in TAStudio (Note: I'm using this rom patched on vanilla super mario world.

  1. Click on frame 10,000 or at some other frame (it really doesn't matter) so that it starts seeking or playing.
  2. Pause
  3. Click on frame 0 or any other frame that has been played, really shouldn't matter.
  4. enjoy

It should honestly be super easy to crash bizhawk this way, for me it has even worked to advance one frame and then go back one frame for bizhawk to crash immediately.

Output

screencap have gotten an InvalidOperationException and some stacktrace in another instance too; don't have screenshot of the stacktrace tho.

Host env.

edit: screencap link -> embed --yoshi

nattthebear commented 4 years ago

What emulation core is being used?

Morilli commented 4 years ago

snes with BSNES core

YoshiRulz commented 4 years ago

The screencap seems to be an SEHException which would be from Rust, but an InvalidOperationException from TAStudio looks like the bug fixed by 757ac4e27. Can you reproduce any crash on a dev build from today?

Morilli commented 4 years ago

Well I'm not managing to reproduce this consistently currently, but I did manage to reproduce this error, and this time even with a stack trace!


************** Ausnahmetext **************
System.Runtime.InteropServices.SEHException (0x80004005): Eine externe Komponente hat eine Ausnahme ausgelöst.
   bei Bizhawk.BizInvokeProxyWaterboxHostNative.wbx_load_state(IntPtr , ReadCallback , IntPtr , ReturnData )
   bei BizHawk.Emulation.Cores.Waterbox.WaterboxHost.LoadStateBinary(BinaryReader br) in D:\GitHub\BizHawk\src\BizHawk.Emulation.Cores\Waterbox\WaterboxHost.cs:Zeile 307.
   bei BizHawk.Emulation.Cores.Nintendo.SNES.LibsnesCore.LoadStateBinary(BinaryReader reader) in D:\GitHub\BizHawk\src\BizHawk.Emulation.Cores\Consoles\Nintendo\SNES\LibsnesCore.IStatable.cs:Zeile 18.
   bei BizHawk.Client.EmuHawk.TAStudio.LoadState(KeyValuePair`2 state)
   bei BizHawk.Client.EmuHawk.TAStudio.StartAtNearestFrameAndEmulate(Int32 frame, Boolean fromLua, Boolean fromRewinding)
   bei BizHawk.Client.EmuHawk.TAStudio.GoToFrame(Int32 frame, Boolean fromLua, Boolean fromRewinding)
   bei BizHawk.Client.EmuHawk.TAStudio.TasView_MouseDown(Object sender, MouseEventArgs e)
   bei System.Windows.Forms.Control.OnMouseDown(MouseEventArgs e)
   bei BizHawk.Client.EmuHawk.InputRoll.OnMouseDown(MouseEventArgs e)
   bei System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
   bei System.Windows.Forms.Control.WndProc(Message& m)
   bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Guess this is just the classic part where it tries to load a savestate that doesn't exist and just throws in some way.

Note that when bizhawk crashes immediately by doing frame advance + going one frame back, this seems to be the line that fails it: https://github.com/TASEmulators/BizHawk/blob/afbce436cd5805395ddaa6eecbb91f7b60842347/waterbox/waterboxhost/src/memory_block/mod.rs#L946

zeromus commented 4 years ago

Have you edited the bk2 by hand (treating it as a zipfile) to remove the greenzone file?

Morilli commented 4 years ago

The .bk2 doesn't contain any greenzone, so no.

YoshiRulz commented 4 years ago

Two other users reported an SEHException when seeking to frame 0 with TAStudio. Both were using BSNES. I tried to repro but couldn't, will try again on Windows.

RetroEdit commented 4 years ago

I was able to reproduce easily on Windows. Saving and then loading a state seems to be broken. You don't need TAStudio open or a movie open.

I'm not sure if it literally affects all savestates, but it seems that way. I've tested saving a state on frame 0, 1, 2, and a miscellaneous one later into the game.


Tested with BizHawk 2.5 and 99599335

Here's a basic workflow for reproducing with no config (or existing save files, though it probably doesn't matter):

This does not seem to occur in 2.4.2.


Also worth noting:

nattthebear commented 4 years ago

Anyone able to reproduce this on linux?

Morilli commented 4 years ago

I tried to test this by using WSL, but it seems there are lots of issues in the linux version, starting with the BSNES core not even working at all, so I cannot test this right now.

nattthebear commented 4 years ago

Huh, bsnses worked in linux last I checked?

Morilli commented 4 years ago

Yeah this might very well all be due to me using WSL2 instead of a real linux system; I just know it's throwing tons of errors and not really working at all.

YoshiRulz commented 4 years ago

Still cannot repro on Linux with RetroEdit's more detailed steps. And though it's true that WSL is different from a real Linux system, natt was using it successfully during development. I've added it to my to-do list of distros.

nattthebear commented 4 years ago

All of my linux work has been WSL2, but anyway that's orthogonal to this issue here. Seems like it's broken on W10 and working on linux (so long as you can get the hawk itself working on linux to start.)

This is not unexpected as there's a difference to how the waterboxhost handles certain BSNES things on windows and linux.

nattthebear commented 4 years ago

@RetroEdit Could you test c86f1e1e98d1c3c45ec99cd0d2f38324db0fa3de and see if the issue still exists? @YoshiRulz Could you do a light regression on bsnes state-ing with c86f1e1e98d1c3c45ec99cd0d2f38324db0fa3de? I doubt anything broke (on linux), but it's nice to be sure.

YoshiRulz commented 4 years ago

Wasn't able to get a crash with the branch.

Morilli commented 4 years ago

With short testing, I couldn't get a crash on that commit anymore. Seems to have fixed the issue.

nattthebear commented 4 years ago

Incorporated into master as 98ad14ff47a0206756f01f4afbe6ae539a612582