Repository navigation
Fix set_entity_data disconnects, overheating damage in sealed rooms, and a CraterCarver data race - #130
Merged
RealAntEngineer merged 3 commits intoOct 19, 2026
Conversation
…ackets RoomShapeSerializer.copy() returned the same instance, so the set_entity_data packet kept a reference to the live box list. searchTopology edited that list in place while the packet was encoded later on a Netty thread, causing a ConcurrentModificationException -> EncoderException and a disconnect for the tracking player. A published RoomShape is now never modified: searchTopology builds a new list and a new shape on every rebuild, so the shape can be shared with packets without a lock or a copy per sync. The one list copy per rebuild replaces the in-place edit.
inO2() consumes the 'inside an oxygen room' flag, and the suffocation and overheating checks each called it. The second call always reported 'no oxygen', so entities standing in a pressurised room took overheating damage. Evaluate it once per check and run the overheating branch only when there is no oxygen.
The carver instance is shared by all chunk-generation worker threads, but its height cache was a plain HashMap, which can corrupt or loop under concurrent access. Use a ConcurrentHashMap.
dhm-msd
marked this pull request as ready for review
October 19, 2026 20:20
Owner
|
Do you use AI ? (simple question, no juging) |
RealAntEngineer
merged commit Oct 19, 2026
0f94fa5
into
RealAntEngineer:1.21.1-release
2 checks passed
Contributor
Author
|
Yes! With lots of tests and review of course. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three small, independent bug fixes (one commit each). Together they fix random player disconnects on busy servers and two smaller issues I found while reading the code.
1. Disconnect:
ConcurrentModificationExceptionwhile encodingset_entity_dataOn our SMP, players got kicked while in a sealed base on the moon (the server was lagging, "Can't keep up, 91 ticks behind"):
Cause:
RoomShapeSerializer.copy()returned the sameRoomShape, so the packet held a reference to the live box list.RoomAtmosphere.searchTopology()edited that list in place, while the packet is encoded later on a Netty thread. A rebuild at the wrong moment throws and the tracking player is disconnected. Lag makes it far more likely. It does not happen in single player, because the host player's connection never goes through the packet encoder.Fix: a published
RoomShapeis never modified.searchTopologybuilds a new list and a new shape on every rebuild, socopy()can return the same instance safely: no lock and no copy per sync. The one list copy per rebuild replaces the old in-place edit. (I considered a mutex, but this avoids contention with the Netty thread and the per-sync allocation.)2. Overheating damage inside sealed rooms
inO2()consumes the "inside an oxygen room" flag, and the suffocation and overheating checks each called it. The second call always said "no oxygen", so entities in a pressurised room took overheating damage. It is now evaluated once per check.3.
CraterCarver.heightMapthread safetyThe carver is shared by all chunk-generation workers but its cache was a plain
HashMap. It is now aConcurrentHashMap.How to reproduce
It needs a real network connection: the host player in single player never goes through the packet encoder, so it doesn't happen there.
Result on 1.7.23: the player is disconnected right away with the trace above (
Failed to encode packet 'clientbound/minecraft:set_entity_data'←ConcurrentModificationException). A wrench click is enough because it fires a block update, and the code then rebuilds the room immediately on the server thread, editing the shape's box list in place while the Netty thread may be encoding it.Testing
set_entity_dataerror in the log.Notes
pr/3builds on this one.