[Crash][1.20.1] Incompatibility with Tiny Skeletons v8.0.1
Lumnyl opened this issue ยท 2 comments
Whenever a Baby Skeleton or Baby Wither Skeleton spawns, the game crashes. Using the Fabric modloader.
Crash logs : https://paste.ee/p/CPomi (regular skeleton) https://paste.ee/p/h6NF5 (wither skeleton)
Link to mod : https://modrinth.com/mod/tiny-skeletons
I also reported the bug to the mod's author.
I've managed to reproduce this crash on both Fabric and Forge. I was initially very confused about the cause, since this crash should not ordinarily be possible.
Normally, Patched tries to capture the FallbackResourceManager
instance since its inject is in a static
method. This is fine because no one calls wrapForDebug
and all the vanilla ones that do are already handled. The instance is also stored in a ThreadLocal
so there can't in theory be any concurrency issues. This of course means that under normal circumstances this crash is impossible.
However, these aren't normal circumstances, and the stacktrace is very misleading about this. I believe what's happened is the following:
- A tiny skeleton tries to render itself
- The skeleton then renders its held item
- This flushes the render buffer, causing Minecraft to render the skeleton itself (so it can setup the state for the item)
- To do this, it must grab the skeleton's texture
- The
MultiPackResourceManager
invokes the correspondingFallbackResourceManager
to grab the texture - Patched captures the
FallbackResourceManager
instance - The
FallbackResourceManager
asks thePackResources
for the resource
And now this is where things get interesting:
- The
BabySkeletonPackResources
asks theMultiPackResourceManager
for the vanilla skeleton texture - The
MultiPackResourceManager
invokes the correspondingFallbackResourceManager
to grab the texture - Patched captures the
FallbackResourceManager
instance - The
FallbackResourceManager
asks thePackResources
for the resource - Patched releases the
FallbackResourceManager
instance (!!!) - The resource is returned to the
BabySkeletonPackResources
- The
BabySkeletonPackResources
returns the rawIoSupplier
And here's the actual crash part:
- The
FallbackResourceManager
receives theIoSupplier
and callswrapForDebug
on it - Patched panics because it no longer has a
FallbackResourceManager
instance to work with (since this was released in step12
)
In summary, the problem is that the MultiPackResourceManager
is queried twice when retrieving a resource, which causes Patched to become confused and crash.
Right now, I can see two options for addressing this problem:
- Patched could capture the
FallbackResourceManager
right before thecreateResource()
call, instead of at the top ofgetResource()
- Tiny Skeletons could query a specific
PackResources
rather than fishing it out of theMultiPackResourceManager
, although this is complicated and comes with its own problems
I can attempt to fix this at some point soon for 1.21.1 (since I'm sure it's still an issue there), but I'm not sure when I'll end up backporting it to 1.20.1. I've had a backport planned for the forty some other features added since then but haven't gotten around to actually backporting them yet.