Skip to content

Catch attribute modification off the main thread.#13639

Open
mbax wants to merge 1 commit intoPaperMC:mainfrom
mbax:asyncAttributes
Open

Catch attribute modification off the main thread.#13639
mbax wants to merge 1 commit intoPaperMC:mainfrom
mbax:asyncAttributes

Conversation

@mbax
Copy link
Contributor

@mbax mbax commented Feb 15, 2026

The clear() call in refreshDirtyAttributes can lead to server crashes if called asynchronously. This async catcher addition should highlight which plugins cause the trouble.

Untested (due to not knowing what plugins cause the issue), but seems to be the only place that this could be getting triggered. Using this PR for publish-pr to attempt helping users, to see if it works out!

Caused by: java.lang.NullPointerException: Cannot invoke "it.unimi.dsi.fastutil.objects.ObjectArrayList.get(int)" because "this.wrapped" is null
	at it.unimi.dsi.fastutil.objects.ObjectOpenHashSet$SetIterator.next(ObjectOpenHashSet.java:577) ~[fastutil-8.5.18.jar:?]
	at net.minecraft.network.protocol.game.ClientboundUpdateAttributesPacket.<init>(ClientboundUpdateAttributesPacket.java:34) ~[paper-1.21.11.jar:1.21.11-113-6103cc7]
	at net.minecraft.server.level.ServerEntity.sendDirtyEntityData(ServerEntity.java:407) ~[paper-1.21.11.jar:1.21.11-113-6103cc7]
	at net.minecraft.server.level.ServerEntity.sendChanges(ServerEntity.java:223) ~[paper-1.21.11.jar:1.21.11-113-6103cc7]
	at net.minecraft.server.level.ChunkMap.newTrackerTick(ChunkMap.java:1059) ~[paper-1.21.11.jar:1.21.11-113-6103cc7]
	at net.minecraft.server.level.ChunkMap.tick(ChunkMap.java:1068) ~[paper-1.21.11.jar:1.21.11-113-6103cc7]
	at net.minecraft.server.level.ServerChunkCache.tick(ServerChunkCache.java:489) ~[paper-1.21.11.jar:1.21.11-113-6103cc7]
	at net.minecraft.server.level.ServerLevel.tick(ServerLevel.java:809) ~[paper-1.21.11.jar:1.21.11-113-6103cc7]
	at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1824) ~[paper-1.21.11.jar:1.21.11-113-6103cc7]
	... 6 more

The clear() call in refreshDirtyAttributes can lead to server crashes if
called asynchronously. This async catcher addition should highlight
which plugins cause the trouble.
@mbax mbax requested a review from a team as a code owner February 15, 2026 18:01
@github-project-automation github-project-automation bot moved this to Awaiting review in Paper PR Queue Feb 15, 2026
@mbax mbax added the publish-pr Enables a workflow to build Paperclip jars on the pull request. label Feb 15, 2026
@papermc-pr-publishing
Copy link

Last updated for: 6973055ee1cfe4560961e003e7caf3953cbb8ce9.

Download the Paperclip jar for this pull request: paper-13639.zip

Maven Publication

The artifacts published by this PR:

Repository Declaration

In order to use the artifacts published by the PR, add the following repository to your buildscript:

repositories {
    maven("https://maven-prs.papermc.io/Paper/pr13639") {
        name = "Maven for PR #13639" // https://github.com/PaperMC/Paper/pull/13639
        mavenContent {
            includeModule("io.papermc.paper", "dev-bundle")
            includeModule("io.papermc.paper", "paper-api")
        }
    }
}

@Warriorrrr
Copy link
Member

I don't think this would be the correct place to add this, the root cause would be plugins interacting with AttributeInstance concurrently, resulting in setDirty being called & mutating attributesToUpdate, or (more unlikely) directly interacting with that set themselves. This method just happens to be where the server trips into it and ends up causing this untraceable error.

@mbax
Copy link
Contributor Author

mbax commented Feb 15, 2026

My assumptions in writing this (I'm curious which are wrong):

  • The exception being fixed only happens when the collection has lost items.
  • The attributesToUpdate only loses items through the clear() call in this method.

@Warriorrrr
Copy link
Member

Seems like my assumption was the one that was wrong, I always thought of this as being comparable to a CME, which traditionally also happens when elements are added during iteration, but doesn't seem to be the case here.

Copy link
Member

@Warriorrrr Warriorrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A plugin you could test this with was recently found in paper-help https://discord.com/channels/289587909051416579/289587909051416579/1460254564480450601

}

private void refreshDirtyAttributes() {
+ org.spigotmc.AsyncCatcher.catchOp("attribute update"); // Paper
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could maybe be using TickThread#ensureTickThread(Entity, String)

@mbax
Copy link
Contributor Author

mbax commented Feb 28, 2026

A user still got the issue with this current code, so there's something missing. https://mclo.gs/YL7HZQ8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

publish-pr Enables a workflow to build Paperclip jars on the pull request.

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

3 participants