mojira.dev
MC-250276

The server sometimes freezes when attempting to locate structures or biomes that are far away

The Bug:

The server sometimes freezes when attempting to locate structures or biomes that are far away.

On several occasions, when I attempted to locate a village using the "/locate" command, the server would freeze and then eventually crash. In my testing, this issue only appeared to occur with structures that are far away such as badlands mineshafts and villages of specific kinds, as I tried to reproduce this with other structures such as mansions and igloos without success.

A crash report regarding this has been attached and can be found below.

Stack Trace:

[^crash-2022-04-22_18.30.50-server.txt]

Description: Watching Server

java.lang.Error: Watchdog
	at [email protected]/jdk.internal.misc.Unsafe.park(Native Method)
	at [email protected]/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252)
	at awo.bq(SourceFile:152)
	at awo.c(SourceFile:142)
	at aeo.a(SourceFile:139)
	at cef.a(SourceFile:196)
	at cei.a(SourceFile:156)
	at cup.a(SourceFile:368)
	at cup.a(SourceFile:347)
	at cup.a(SourceFile:287)
	at abs.a(SourceFile:52)
	at abs.a(SourceFile:38)
	at abs$$Lambda$3680/0x0000000801395b60.run(Unknown Source)
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:263)
	at com.mojang.brigadier.CommandDispatcher.execute(CommandDispatcher.java:177)
	at dr.a(SourceFile:262)
	at afi.a(SourceFile:1270)
	at afi.a(SourceFile:1254)
	at afi.a(SourceFile:1237)
	at we.a(SourceFile:30)
	at we.a(SourceFile:7)
	at ry.a(SourceFile:22)
	at ry$$Lambda$5081/0x0000000801777558.run(Unknown Source)
	at aab.run(SourceFile:18)
	at awo.d(SourceFile:157)
	at aws.d(SourceFile:23)
	at net.minecraft.server.MinecraftServer.b(SourceFile:782)
	at net.minecraft.server.MinecraftServer.d(SourceFile:158)
	at awo.x(SourceFile:131)
	at net.minecraft.server.MinecraftServer.bf(SourceFile:764)
	at net.minecraft.server.MinecraftServer.x(SourceFile:758)
	at awo.bp(SourceFile:116)
	at net.minecraft.server.MinecraftServer.w(SourceFile:742)
	at net.minecraft.server.MinecraftServer.v(SourceFile:675)
	at net.minecraft.server.MinecraftServer.a(SourceFile:263)
	at net.minecraft.server.MinecraftServer$$Lambda$4253/0x000000080142d578.run(Unknown Source)
	at [email protected]/java.lang.Thread.run(Thread.java:833)

Steps to Reproduce:

  1. Launch the latest snapshot of Minecraft and create a new world with cheats enabled.

  2. Attempt to locate a savanna village by using the command provided below.

    /locate structure minecraft:village_savanna
  3. If the server didn't crash, teleport yourself a fair distance away from your current location and attempt to locate another village again by using the commands provided below.

    /tp @s ~10000 ~ ~
    /locate structure minecraft:village_savanna
  4. Take note as to whether or not the server sometimes freezes when attempting to locate structures or biomes that are far away.

Observed Behavior:

The server freezes.

Expected Behavior:

The server would not freeze.

Linked issues

Attachments

Comments 13

user-f2760

I would reword this report if I were you; this is the server freezing (also happens in singleplayer), not crashing (not in singleplayer); the crashing is caused by watchdog, which is a forced crash if the server takes too long (and can be changed in the server.properties, even turned off).

Avoma

Thank you @unknown for this information; I've updated this ticket accordingly. 🙂

clamlol

Affects 1.19-pre1. (Also Mojang if you're revisiting the /locate implementation maybe take a look at MC-138887?)

Flashbulb

This also happens very often with custom structures.

Avoma

Further investigating concludes that this issue is not exclusive to villages; I also experienced this when attempting to locate a badlands (mesa) mineshaft. Since I'm the reporter of this ticket, I've made the appropriate changes to reflect this new information.

3 more comments
Jon1337

In 23w32a

Brevort

Affects the new pre release 1.20.2-pre 1. Had really bad lag spike when opening a cartographer when it tried to find a witch hut.

clamlol

Here's the situation as of 24w04a, as far as I can tell.

In the past, extended server freezes (often leading to crashes on dedicated servers) could be caused by locating certain types of structures, most notably buried treasures (MC-249136), or by trying to locate a structure which does not exist nearby/in the current dimension. Both of these issues have now been fixed, so any lag from running the locate command will rarely last more than a few seconds- still significant enough to interfere with mining and combat, but not even close to triggering the watchdog on dedicated servers. As to whether optimizations to the core locate algorithm could further reduce the server hang time, I suspect* that some improvements could be made but that bringing the runtime below 0.05s (1 tick) 100% of the time is unrealistic. This being the case, unless Mojang has some other threshold of when server hangs form /locate constitute a bug, they should either:

  • Resolve this as Won't Fix, since the most egregious cases have been dealt with and no further improvements can be made without substantial changes; or,

  • Leave this open pending a rewrite of the command system which allows expensive commands like /locate to run on a separate thread and return their results/success at a later time or not at all. Of the existing commands, /locate is probably the only one that would use this functionality.

Personally I would recommend the latter. The locate algorithm is most often used in creative worlds and when generating structure maps, so the result and success values aren't really essential. I did once make an algorithm for a data pack which used the result value as part of a ray marching algorithm to locate and teleport the player to the nearest structure (the structure in question being an entry/exit portal in a custom dimension), and there are probably other niche applications for this value, but in the grand scheme of things safeguarding server performance is more important.

----------------------------------

*To my knowledge no one has analyzed the locate algorithm in detail and suggested efficiency improvements, but the existence of MC-138887 proves that it isn't perfect as is.

Minecraft386882

Can confirm for 1.21.3

KawaMood

Can confirm for 1.21.5

Avoma

(Unassigned)

Confirmed

Platform

Important

Crash, Performance

1.16 Pre-release 6, 1.16 Pre-release 7, 1.16 Pre-release 8, 1.16 Release Candidate 1, 1.16, ..., 1.20.2 Pre-release 1, 1.20.2, 24w04a, 1.21, 1.21.3

Retrieved