[Bug] MC-89146 fix: NPE in LevelChunk.clearAllBlockEntities when a block entity removal re-enters the linked map
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 58/100
Hướng nghiên cứu
Start by locating the MC-89146 patch and its change to LevelChunk.clearAllBlockEntities; the crash trace identifies the failing loop at LevelChunk.java:697. Check how block entity removal can mutate the linked map during iteration, then reproduce the reported chunk reload sequence and verify all block entities are removed without a crash. The issue suggests iterating over a snapshot as one possible fix.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Debugify 26.3.0.0 is still the newest 26.3 release (re-checked 19 Nov 2026 against the newest 26.3 release on Modrinth).
Bug Description
Crash (client, on chunk reload near a jukebox):
java.lang.NullPointerException: Packet handling error
at it.unimi.dsi.fastutil.objects.Object2ObjectLinkedOpenHashMap$1.forEach(Object2ObjectLinkedOpenHashMap.java:1699)
at net.minecraft.world.level.chunk.LevelChunk.clearAllBlockEntities(LevelChunk.java:697)
at net.minecraft.world.level.chunk.LevelChunk.replaceWithPacketData(LevelChunk.java:539)
at net.minecraft.client.multiplayer.ClientChunkCache.replaceWithPacketData(ClientChunkCache.java:118)
at net.minecraft.client.multiplayer.ClientPacketListener.handleLevelChunkWithLight(ClientPacketListener.java:905)
The client is disconnected with "Packet handling error".
What happens
- MC-89146 replaces
ChunkAccess.blockEntitieswith anObject2ObjectLinkedOpenHashMap. - On
level_chunk_with_light,clearAllBlockEntitiesrunsblockEntities.values().forEach(BlockEntity::setRemoved). JukeboxBlockEntity.setRemovedfires level event 1011; the client handler callsnotifyNearbyEntities. Cooking for Blockheads hooks that method and callslevel.getBlockEntityon 343 nearby positions. VanillaLevelChunk.getBlockEntity(..., CHECK)removes entries whoseisRemoved()is already true, so the map is modified during theforEach.- Fastutil's linked-map
forEachcaches the next slot index before calling the consumer. After the reentrant removal shifts the next entry (here a decorated pot) back one slot, the cached slot is empty andnullis passed tosetRemoved-> NPE. No null value is ever stored (containsValue(null)is false before and after).
We reproduced this offline with the real chunk data (8 block entities: spawner, chests, brushable blocks, jukebox, decorated pot) and the real jukebox / Cooking for Blockheads / fastutil code: NPE with the linked map; with vanilla's Object2ObjectOpenHashMap the same sequence completes all 8 removals. Turning off "MC-89146" in config/debugify.json avoids it, but loses that fix.
Suggested fix: keep the linked map but make the clear loop tolerate reentrant removal, e.g. iterate over a snapshot when the map is the linked one:
new ArrayList<>(this.blockEntities.values()).forEach(BlockEntity::setRemoved);
(or redirect clearAllBlockEntities to do that). Cooking for Blockheads' lookup during removal is the trigger, but any mod that calls getBlockEntity from a setRemoved side effect can hit this.
Other mods involved: Cooking for Blockheads 26.3.0.2, Lootr 1.25.42.124 (its block entities were in the chunk; incidental). Multiplayer, Fabric 26.3 pack with ~430 mods.
Version
Debugify 26.3.0.0 (Minecraft 26.3), MC-89146 enabled (default)
Fabric/Quilt Loader Version
Fabric Loader 0.20.1, Fabric API 0.165.2+26.3
Checklist
- This bug has not been reported already (searched MC-89146, clearAllBlockEntities, "Packet handling error").
- I am on the most up to date version (26.3.0.0 is the newest 26.3 build).
- Ngôn ngữ chính
- Java
- Star
- 215
- Fork
- 51
- Merge trung bình
- 1 giờ 42 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của isXander/Debugify
-
[UI] MC-259512 has the wrong tooltip description (duplicate of MC-206540)Có thể đã có người làm @kiwiaraga2000 đã nhận 139 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
-
Mention that this is a mod specifically for Minecraft: Java Edition in the repository descriptionĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 65/100
-
can i port this to neoforgeĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 20/100
Tất cả issue của isXander/Debugify
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
SmartPack/PackageManager#186 ·
-
Area: Java feature request needs triage OS: Windows
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
actions/runner-images#15457 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
iOS CocoaPods build fails: Package.swift included in sources causes No such module 'PackageDescription'Có thể đã có người làm @dattm97 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
MewX/light-novel-library_Wenku8_Android#253 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jarvis2f/telegram-files#160 ·