Fix NPE in CarryOnDataSyncHandler causing server-wide disconnects on player death#974
Open
Mheaus wants to merge 1 commit into
Open
Fix NPE in CarryOnDataSyncHandler causing server-wide disconnects on player death#974Mheaus wants to merge 1 commit into
Mheaus wants to merge 1 commit into
Conversation
…player death When any player dies, NeoForge triggers an attachment sync for all players to all observers. sendToPlayer() already guards against syncing data *from* dead/just-spawned players, but not *to* players in those states. When the recipient is dying or respawning, the RegistryFriendlyByteBuf internals have a null ObjectArrayList (wrapped == null), causing: Failed encoding custom payload carryon:sync_carry_data: NullPointerException: Cannot invoke ObjectArrayList.get(int) because 'this.wrapped' is null This kicks every connected player simultaneously. Reliably reproducible: any player death while others are online. Reported in Tschipp#945, Tschipp#961, Tschipp#972. Fix: apply the same liveness guards to the recipient (to) that already exist for the holder (player).
1 task
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.
Problem
When any player dies, NeoForge triggers an attachment sync for all players to all observers.
sendToPlayer()already guards against syncing data from dead or just-spawned players, but not to players in those states.When the recipient (
to) is dying or respawning, theRegistryFriendlyByteBufinternals have a nullObjectArrayList(wrapped == null), causing:This crashes the packet encoder and kicks every connected player simultaneously. Reliably reproducible: any player death while others are online. Reported in #945, #961, #972.
Fix
Apply the same liveness guards to the recipient (
to) that already exist for the holder (player) — one extraifblock, mirroring the existing logic and its comments:Testing
Reproduced on a NeoForge 21.1.234 server with multiple players online. Before the fix: any player death causes a server-wide disconnect. The fix has not been tested yet, I generated the pr with claude code, I hope that this can help in any way,
Feel free to leave a comment or review to let me know if it's ok or not.
Note: the
1.21.1branch already addresses this differently by commenting out the sync handler entirely. This PR brings an equivalent fix to1.21.11(and by extension1.21.8/1.21.9) where the sync handler is still active.