mojira.dev
MC-249136

Freeze/server-side lag spike sometimes occurs when attempting to locate a buried treasure or opening/breaking a chest containing a map

The bug

A server-side lag spike sometimes occurs when attempting to locate a buried treasure or opening/breaking a chest containing a map. Some players have reported crashes caused by this issue, one of which is attached.

Code analysis

Code analysis by @unknown can be found in this comment.

Linked issues

Attachments

Comments 31

ampolive

Clones MC-236740, although not nearly as bad.

Nathan

I have this happen in 22w14a and 15a but it actually crashes my server.

Seed: 1248939201

Coords of close chest that will crash server reliably: /execute in minecraft:overworld run tp @s -170.76 64.00 488.14 -367.35 52.65

I will attach a crash report if this lets me. When I run in normal mode there's only a lag but running as a docker container as server it crashes 100% of the time.

Nathan

This is my docker-compose config

version: '3'services:
  minecraft:
    ports:
      - "25584:25565"
    networks:
      - minecraft
    volumes:
      - "/opt/minecraft_snapshot/data:/data"
    environment:
      VERSION: "22w15a"
      EULA: "TRUE"
      TZ: "US/Mountain"
      MAX_MEMORY: 16G
      MAX_BUILD_HEIGHT: 320
      VIEW_DISTANCE: 10
      MAX_PLAYERS: 5
      CONSOLE: "false"
    image: itzg/minecraft-server:java17
    restart: always
    logging:
      driver: loki
      options:
        loki-url: "http://192.168.1.110:3100/loki/api/v1/push"
  exporter:
    image: 'nkimball/minecraft_exporter:v6'
    environment:
      RCON_HOST: minecraft
      RCON_PORT: 25585
      RCON_PASSWORD: redacted
    ports:
      - 9784:8000
    networks:
      - minecraft
    volumes:
      - /opt/minecraft_snapshot/data/Snapshot:/world:ro
    depends_on: 
      - minecraft
    restart: alwaysnetworks:
  minecraft:
    driver_opts:
      com.docker.network.bridge.name: br_snapshot
Nathan

Also I should note if I play a regular game and open to LAN it doesn't crash, only the server.jar.

ampolive

This actually seems to also affect other things that are relatively rare, including specific villages (if you search for a snowy village about 4000-5000 blocks away, the lag spike will be very similar). I don't know if it is the same issue.
Edit: it's not the same issue, that is MC-250276.

21 more comments
Bytzo

This appears to be fixed in Minecraft version 24w04a. I have tested this on the game client and have looked at the code, which both indicate this being fixed.

The method isStructureChunk in StructurePlacement was refactored so that the logic for using a structure's frequency reduction method is in its own method, called applyAdditionalChunkRestrictions. This method is then used before starting to check for a structure in checkStart.

This is a much better solution than the solution I previously wrote since the logic for the frequency reduction method does not require access to a ChunkGeneratorStructureState, so refactoring it out allows for a much cleaner check in StructureCheck. I wrote my solution was in a way so that the game logic would not have to be copied to the mod containing the fix, and I determined that extracting the logic from isStructureChunk would be difficult. So, instead I used the whole method which required a very messy way of accessing a ChunkGeneratorStructureState and structure placement within StructureCheck.

Since this appears to be fixed as of now, I believe this issue can be marked as resolved.

Bytzo

Oops, it looks like this was already marked as resolved while I was checking and writing the below comment. I probably should have refreshed the page before posting, sorry!

Eagle7z

playing on version 1.20.4, vanilla server running on Linux, issue is definitely not resolved, found 2 separate shipwreck chests causing the server to crash

ampolive

1.20.4 is an affected version. This issue was fixed on 24w04a, a 1.20.5 snapshot.

Jolo_Janssen

I ran into this issue on a 1.21.1 server. The server lagged and then crashed when opening underwater loot chests with buried treasure maps.

ampolive

(Unassigned)

Confirmed

Platform

Normal

Maps, Performance, World generation

buried-treasure-map, lag-spike, map, shipwreck

22w11a, 22w12a, 22w15a, 22w17a, 1.19 Pre-release 1, ..., 23w32a, 23w33a, 1.20.2, 1.20.3 Pre-Release 2, 1.20.4

24w04a

Retrieved