The bug
It appears net.minecraft.server.rcon.thread.GenericThread (Mojang name) respectively its subclasses are not thread-safe:
GenericThread.running: Is modified outside of thread (stop()), but its value is checked withinrun(). There are no memory visibility guarantees becauserunningis not volatile.GenericThread.stop(): Calls non-thread-safe methods whenthread.jointimes out (might be intended).
Comments 2
This no longer seems to be an issue as of 1.21.11:
runningis not volatile
The field is explicitly declared:
protected volatile boolean a;Full memory visibility is guaranteed between the main thread writing this.a = false in stop() and the background thread reading it in while (this.a).
stop() calls non-thread-safe methods on timeout
Every method called after join() times out, isAlive(), getState(), and interrupt() are JDK Thread primitives explicitly designed by the Java specification for cross thread invocation.
public synchronized void b() {
this.a = false;
...
this.c.interrupt();
...
this.c = null;
}
Is this still a problem?