Hi Matt and others, If you're not already aware, there is a function provided by sci_memory called debug_win32_memory() to automatically check for heap corruption as the program runs. Before I speak about using it, however, change this line in the above function in sci_memory.c from: int tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); to: static int tmpFlag; tmpFlag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); before you use it! Anyway, if you put a call to debug_win32_memory() somewhere appropriate before problems occur: debug_win32_memory(1); /* checks heap after every memory allocation and deallocation */ debug_win32_memory(3); /* does the above, as well as checking for memory leaks on program exit, as well as checking for re-use of free'd memory */ With a parameter of 1, things are slow. With a parameter of 3, they are virtually unusable and deadlocks appear to occur (but be patient!). In any case, once you've put that line of code in, if you go to Build / Start Debug... / Go, you should find that VC++ stops execution whenever heap corruption occurs. When this happens, I'd look at the code it brings on the screen (don't forget to change thread focus to see what the sound thread is doing at that point or vice versa). Also make sure you're looking at the Debug tab (the one between 'Build' and 'Find in Files 1') to see if you get any errors. Hmmm... maybe I should add this to the Win32 readme. Having said all that however, I'm unsure as to how helpful it is for the save game problem we are currently having with LSL2. Having the above setting turned on makes FreeSCI stop in exactly the same place with the same message. :-( I might look into seeing if I can add more Win32 debugging stuff to sci_memory.c around the sci_?alloc calls. It's absolutely possible that this is complete bunkum, but I also wonder if some of the problems we're having that are specific to Win32 have something to do with the transfer of memory between fsci.dll and freesci.exe. I had trouble with that when I was writing sci_memory.c, hence why that file is included in both projects rather than just one. Cheers, Alex.
