ScalarR not stopping
The highlighted comment was created in this revision.
Hi, I observe the following in the output of the rumble client
Fighting battle 44 ... aaa.r.ScalarR 0.005h.053,jk.mega.DrussGT 3.1.7 Robot aaa.r.ScalarR 0.005h.053 (1) is not stopping. Forcing a stop. Robot aaa.r.ScalarR 0.005h.053 (1) is not stopping. Forcing a stop. Unable to stop thread: aaa.r.ScalarR 0.005h.053 (1) Unable to stop thread: aaa.r.ScalarR 0.005h.053 (1)
and the client seems to be running this battle with 100% CPU for at least several minutes (about 5). Then roborumble continued.
I am not sure where to search for the problem but there is something strange going on. I am running everything with
openjdk version "11.0.16" 2022-07-19 OpenJDK Runtime Environment (build 11.0.16+8-post-Debian-1deb11u1) OpenJDK 64-Bit Server VM (build 11.0.16+8-post-Debian-1deb11u1, mixed mode, sharing)
Thanks for reporting. I'm not able to reproduce this problem on both Java 11 and Java 17 (both on macOS, HotSpot). Can you try with HotSpot as well? I'll also have a check on the logic.
What is HotSpot?
Could it be Kotlin related? My roborumble (official one) clients report this error at the startup time
java.lang.IllegalAccessError: class kotlin.collections.CollectionsKt cannot access its superclass kotlin.collections.CollectionsKt___CollectionsKt (kotlin.collections.CollectionsKt is in unnamed module of loader net.sf.robocode.host.security.RobotClassLoader @586bc8ed; kotlin.collections.CollectionsKt___CollectionsKt is in unnamed module of loader java.net.URLClassLoader @3d494fbf)
I don't think it has something to do with Kotlin, but I generally delete Kotlin jars to suppress this error.
I had a check at the round finalization logic of robocode, it seems that after user specified run() exits, control flow will be handled to `HostingRobotProxy.run`, which calls `BasicRobotProxy.waitForBattleEndImpl`. The logic here had some potential bugs, e.g. when receiving `InterruptedException`, it merely wakes up the thread instead of letting the thread exit gracefully. Not sure what triggered a bug here on some platform though...