Savage & Ravage

Savage & Ravage

26M Downloads

[1.19.2] RandomSource crash caused by Savage and Ravage

TelepathicGrunt opened this issue · 6 comments

commented

Crashlog from the user: https://paste.ee/p/tcl0e

The problematic line:

a user came into Yung’s discord asking for help with solving a RandomSource crash. I took a look and sure enough, this code in Savage and Ravage is not threadsafe and using the wrong RandomSource.

The technical reason behind this is that Minecraft’s world generation is multithreaded but RandomSource is not threadsafe. So if during worldgen, someone grabs the ServerLevel instead of WorldGenRegion and uses the random in ServerLevel, then they risk a crash if they use that random at the exact same time as the server thread using the random. This causes the two threads to try and ask the RandomSource for a value at the same time which is illegal and causes a crash.

Here in Savage and Ravage, this mixin into finalizeSpawn runs during worldgen when the Pillager finishes spawning from structures or features or whatever. But this mixin is using the ServerLevel’s random that is passed into the entity’s constructor when entities are first created. Never use this level’s random. Instead, all living entities have their own builtin-field that initializes a RandomSource just for that entity. Use this RandomSource always when working with the entity anywhere (but especially within the entity’s constructor or initialization like where this mixin is)

Switch to this RandomSource and that should greatly help reduce people crashing at completely random times in the overworld and were unable to track down the mod.

Be sure to check all your other mixins and code as well to make sure they all have the correct randomsource usage too. I had a similar crash as well until I refactored my mod to use the entity’s randomsource whenever I had an entity passed in a method’s constructor (like block’s entityInside method) or is within an entity’s class.

commented

Just experienced this crash too. It's a pretty frequent one.
crash-2022-10-19_20.17.46-server.txt

commented

This is happening here too, i thought it was some incompatibility with It Takes Pillage or Better Villages, but apparently not, since @ZilverLazarus has the same error log as mine, and i tested takespillager without savage and ravage for about an hour, and the crash didn't occur
crash-2022-10-20_20.27.26-server.txt

commented

https://mclo.gs/KJfZzN4 I have been having the same issue, any tips on stopping the crashes without having to completely restart my server?

There is no fix aside from removing the mod entirely until authors make an update per the suggestion from TelepathicGrunt.

commented

Yep. Looking at the code, I do not see any config option to disable the mixin or the random usage inside the mixin. So this will have to be dealt with by the mod authors. No workarounds for users to do

commented

https://mclo.gs/KJfZzN4 I have been having the same issue, any tips on stopping the crashes without having to completely restart my server?

commented

crash-2022-12-21_16.33.10-server.txt
I'm having this problem too, I think this is why the mod not being downloaded as before