Fix TamableAnimal race condition #426

Open
Dueris wants to merge 1 commit from CraftCanvasMC/fix/tamableanimal-racecond into ver/1.21.11
Dueris commented 2026-01-01 01:37:53 +01:00 (Migrated from github.com)

With Folia, teleporting a tamed animal, like a wolf, to a player that is now not in the same region, is technically thread-safe because of Folias current patch. However, there is a race condition where if the chunk the tamed animal is trying to teleport to isn't loaded yet, it crashes the server because when it is trying to check if it CAN teleport, it tries to check blocks in that chunk, but if the chunk isn't loaded, it tries to load it. Thus causing a crash since if the target location isn't in the same region, it will kill the server because of a bad access(trying to load chunk outside owning region).

The fix proposed here just checks if the chunk is loaded first, and if it is loaded, then it will proceed. Otherwise, returns false.

With Folia, teleporting a tamed animal, like a wolf, to a player that is now not in the same region, is technically thread-safe because of Folias current patch. However, there is a race condition where if the chunk the tamed animal is trying to teleport to isn't loaded yet, it crashes the server because when it is trying to check if it ***CAN*** teleport, it tries to check blocks in that chunk, but if the chunk isn't loaded, it tries to load it. Thus causing a crash since if the target location isn't in the same region, it will kill the server because of a bad access(trying to load chunk outside owning region). The fix proposed here just checks if the chunk is loaded first, and if it is loaded, then it will proceed. Otherwise, returns false.
This pull request can be merged automatically.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin CraftCanvasMC/fix/tamableanimal-racecond:CraftCanvasMC/fix/tamableanimal-racecond
git switch CraftCanvasMC/fix/tamableanimal-racecond

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch ver/1.21.11
git merge --no-ff CraftCanvasMC/fix/tamableanimal-racecond
git switch CraftCanvasMC/fix/tamableanimal-racecond
git rebase ver/1.21.11
git switch ver/1.21.11
git merge --ff-only CraftCanvasMC/fix/tamableanimal-racecond
git switch CraftCanvasMC/fix/tamableanimal-racecond
git rebase ver/1.21.11
git switch ver/1.21.11
git merge --no-ff CraftCanvasMC/fix/tamableanimal-racecond
git switch ver/1.21.11
git merge --squash CraftCanvasMC/fix/tamableanimal-racecond
git switch ver/1.21.11
git merge --ff-only CraftCanvasMC/fix/tamableanimal-racecond
git switch ver/1.21.11
git merge CraftCanvasMC/fix/tamableanimal-racecond
git push origin ver/1.21.11
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Minecraft/Folia!426
No description provided.