mojira.dev
MC-168663

net.minecraft.server.rcon.thread.GenericThread is not thread-safe

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 within run(). There are no memory visibility guarantees because running is not volatile.

  • GenericThread.stop(): Calls non-thread-safe methods when thread.join times out (might be intended).

Comments 2

Is this still a problem?

This no longer seems to be an issue as of 1.21.11:

running is 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;
}

marcono1234

(Unassigned)

Plausible

Platform

Low

Networking

1.15.1

Retrieved