View Single Post
Seren Seren's Avatar

JCF Member

Joined: Feb 2010

Posts: 851

Seren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to allSeren is a name known to all

Jul 19, 2017, 03:17 AM
Seren is offline
Reply With Quote
Yeah, that's the address. The line of Assembly that crashes your game is <code>mov ecx, [eax]</code>. It accesses whatever <code>eax</code> is pointing at, and <code>eax</code> is previously loaded from a variable that, presumably, another thread is supposed to write to. JJ2 doesn't correctly test whether this already happened or not, so sometimes it's null, hence the attempt to read from <code>0x0</code>. Thus the proper solution would probably be to create a lock to prevent JJ2 from entering that part until the other thread is finished.

We're not going to be doing that. It's complex and, in code we don't entirely understand, has a lot of room for error. What JJ2+ does is simply test whether the pointer is null and not perform any of the following actions if so. This is a moderately good solution but it also means injecting more code than there's room for. It works for us because we have a setup where we can perform jumps from JJ2 code to our own and back, but it's not easy to do otherwise. You can't insert additional bytes in the middle of the executable without breaking everything, so it may not be a viable solution for you.

You could easily always terminate execution of the function early but this would probably be exactly equivalent to just disabling your music output altogether. Alternatively you could delay the execution of this function more but it wouldn't be guaranteed to eliminate crashes, only make them more sparse. I'll get back to you if I find a solution that's more worthwhile.

I am an official JJ2+ programmer and this has been an official JJ2+ statement.