fix a libco issue that was breaking xorstate consistency

This commit is contained in:
nattthebear 2017-06-10 18:20:58 -04:00
parent ba7543c19a
commit dde953d612
4 changed files with 18 additions and 0 deletions

View File

@ -756,6 +756,19 @@ namespace BizHawk.Emulation.Cores.Waterbox
{
using (this.EnterExit())
{
// if libco is used, the jmp_buf for the main cothread can have stack stuff in it.
// this isn't a problem, since we only savestate when the core is not running, and
// the next time it's run, that buf will be overridden again.
// but it breaks xor state verification, so when we seal, nuke it.
// this could be the responsibility of something else other than the PeRunner; I am not sure yet...
IImportResolver libco;
if (_exports.TryGetValue("libco.so", out libco))
{
Console.WriteLine("Calling co_clean()...");
Marshal.GetDelegateForFunctionPointer<Action>(libco.SafeResolve("co_clean"))();
}
_sealedheap.Seal();
foreach (var h in _heaps)
{

Binary file not shown.

View File

@ -9,6 +9,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
@ -23,6 +24,10 @@ static void crash() {
assert(0); /* called only if cothread_t entrypoint returns */
}
void co_clean() {
memset(co_active_buffer, 0, sizeof(co_active_buffer));
}
cothread_t co_active() {
if(!co_active_handle) co_active_handle = &co_active_buffer;
return co_active_handle;

Binary file not shown.