mojira.dev
MC-312695

Enabling Code of Conduct on Vanilla Servers sometimes crashes the server

If you set up a brand new Minecraft 26.3 vanilla server, and just set enable-code-of-conduct=true in server.properties, add some code of conduct to codeofconduct/en_us.txt, accepting the code of conduct will sometimes crash the server.

Make sure to be whitelisted / turn whitelist off, because code of conduct is only shown after the whitelist check.

For reproducing the bug, I created an example Docker setup that demonstrates the symptom: https://gist.github.com/LCLPYT/94070be90b48d54e8bdc6e1f8c4de93f (it wouldn’t let me upload tar / zip archives here).

I found this bug while developing a custom minigame server through debugging, though the bug is in vanilla.
The packet handler for the accept code of conduct packet finishes the task in the network thread, instead of the server thread.
This seems to cause a race-condition somewhat reliably on my system, crashing sometimes in chunk loading or spawn finding.
During testing the crash occurred 2/9 times, so it likely depends on some race of the configuration phase / world loading…
An example crash log can be found in the attachments.

Solution should be just be to use ensureRunningOnSameThread as is done in the other handlers as well in ServerConfigurationPacketListenerImpl.

Environment

Arch Linux (linux 7.2.9) and Ubuntu 25.10 (linux 6.17.0); Java is Eclipse Temurin 25 JRE

Attachments

Comments 4

Hi!
Thank you for your report!

Please attach the crash report and logs here.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

Hi! As mentioned already, it would be incredibly helpful if you can attach any crash logs. I’m resolving this ticket as Awaiting Response until then. The ticket will automatically be reopened when you reply.

Hi,

sorry, for some reason the log file doesn’t seem to have uploaded the first time.
Here you go:

[media]

A few additional details for developers:

The crash happens because of a race-condition in the view distance manager. I’ve initially encountered it on an old thinkpad, with a slower CPU…
It only seems to happen if no player data exists for the joining player; just after accepting the code of conduct of the server.

This happens on the stock vanilla 26.3 server, without any mods / modloaders etc.

It’s pretty hard to replicate on my machine with a more powerful CPU (Intel i5 13600 KF).
However, I was able to reproduce it using a custom datapack keeping the chunk loader busy and a python script sending join packets repeatedly.

I’ve updated the GitHub Gist so others can easily reproduce this using docker.

As I said already, the fix is simply adding one line to the code of conduct packet handler in ServerConfigurationPacketListenerImpl:

	@Override
	public void handleAcceptCodeOfConduct(final ServerboundAcceptCodeOfConductPacket packet) {
	    // this line here is missing in the vanilla game
		PacketUtils.ensureRunningOnSameThread(packet, this, this.server.packetProcessor());
	
		this.finishCurrentTask(ServerCodeOfConductConfigurationTask.TYPE);
	}

I needed to fix this problem on my thinkpad server, so I installed the Fabric mod loader and added this missing line via a Mixin.
Since then, I’ve never encountered the crash again…

Also here is another crash report that was generated, where you can see the server thread exception:

[media]

LCLP

(Unassigned)

Unconfirmed

26.3

Retrieved