Ismoh / NoitaMP

WIP! Not working, atm! NoitaMP, Noita Multiplayer: First synchronous multiplayer mod for Noita!
GNU General Public License v3.0
116 stars 12 forks source link

Client sometimes crashing when projectile collides #37

Closed shebpamm closed 2 years ago

shebpamm commented 2 years ago

When client fires spark bolts, sometimes clients game crashes when the projectile collides.

Firing projectiles as server does not crash clients game and servers game has never crashed.

Exit code is 0xc0000005 which means STATUS_ACCESS_VIOLATION so we are writing to an inaccessible memory location.

No Lua error is produced as the whole game crashes.

My guess is that this could be caused by the projectile being destroyed by colliding and then the server sending a despawn command to the client, making the client try to despawn an already destroyed entity.

Originally discussed in #28, could be fixed by #27

Environment: NoitaMP master branch noita_dev.exe used with -lua_debug argument Decoda attached as debugger to client

Ismoh commented 2 years ago

If you like, you can create a branch for this out of develop and pull branch of #27 and have a look in entity_manager.lua. There is a despawn function. There already should a check, but I am glad to see you improving this! Problem might be the Noita API method IsEntityAlive (or kinda that naming). Maybe this is allocating memo, which isnt used or free anymore.

shebpamm commented 2 years ago

Upon further testing it looks like actually when hitting some materials, small particles are spawned and syncing those crashes the game. So #27 and whitelisting/blacklisting syncable entities should fix this.

Ismoh commented 2 years ago

Thanks for having a look again! I really appreciate it.

Question is which entities should be synced or not. Research needed?

Do you mind to clarify, which entities should be blacklisted? I am thinking of entities added by other mods. We are not able to know all entities, which might cause issues or a crash.

I more hope, that the de/serialisation was or is the problem. Will see in #27

Ismoh commented 2 years ago

For clarification I would suggest to create a branch out of develop, as you already said, but wont pull or merge #27 into it, because I did a huge rework! I mentioned it some comments above and thought about it. I wouldnt do so anymore :D

I think it's easier to add the blacklist in this branch and create a PR then into develop, when you are happy with your changes.

Just fyi!

Thank you really much!

Ismoh commented 2 years ago

@shebpamm Fyi, I already implemented a black- and whitelist, because the crashes drove me crazy.

27 is not done yet, but here are the lists:

https://github.com/Ismoh/NoitaMP/blob/27-rework-networkcomponents/mods/noita-mp/files/scripts/util/EntityUtils.lua#L84-L91

It would be awesome to be able to set this list via a config file, which will be used in modsettings, so that the user is able to edit the file and also add stuff while playing in modSettings.

Are you interested in implement this, when #27 is done? Or you can already start with this, but have to create your branch out of #27 branch. You can create a new issue for this. Just feel free and do as you like!

Please give me a shout, that I am aware of, thank you very much.

Fyi no crashes yet, but only tested with Server. Client rework isnt done yet.

Ismoh commented 2 years ago

No crashes until now. Tested a lot in #48. I'll close this now.