cc-tweaked / CC-Tweaked

Just another ComputerCraft fork
https://tweaked.cc
934 stars 211 forks source link

[crashed] java.lang.NoClassDefFoundError (ComputerActionServerMessage & UserLevel) #366

Closed luochen1990 closed 4 years ago

luochen1990 commented 4 years ago

Useful information to include:

The first crash report (only some abstruct here, if you need the full one please tell me).

java.lang.NoClassDefFoundError: dan200/computercraft/shared/network/server/ComputerActionServerMessage$1
    at dan200.computercraft.shared.network.server.ComputerActionServerMessage.handle(ComputerActionServerMessage.java:45) ~[?:1.86.2] {re:classloading}
    at dan200.computercraft.shared.network.server.ComputerServerMessage.handle(ComputerServerMessage.java:57) ~[?:1.86.2] {re:classloading}
    at dan200.computercraft.shared.network.NetworkHandler.lambda$null$2(NetworkHandler.java:119) ~[?:1.86.2] {re:classloading}
    at net.minecraftforge.fml.network.NetworkEvent$Context.enqueueWork(NetworkEvent.java:215) ~[?:?] {re:classloading}
    at dan200.computercraft.shared.network.NetworkHandler.lambda$registerMainThread$3(NetworkHandler.java:119) ~[?:1.86.2] {re:classloading}
    at net.minecraftforge.fml.network.simple.IndexedMessageCodec.lambda$tryDecode$3(IndexedMessageCodec.java:124) ~[?:?] {re:classloading}

After it crashs the first time, I also tried to retry a second time, and this time the error report is somehow different:

java.lang.NoClassDefFoundError: dan200/computercraft/shared/command/UserLevel$1
    at dan200.computercraft.shared.command.UserLevel.toLevel(UserLevel.java:42) ~[?:1.86.2] {re:classloading}
    at dan200.computercraft.shared.command.UserLevel.test(UserLevel.java:70) ~[?:1.86.2] {re:classloading}
    at dan200.computercraft.shared.command.UserLevel.test(UserLevel.java:18) ~[?:1.86.2] {re:classloading}
    at com.mojang.brigadier.tree.CommandNode.canUse(CommandNode.java:66) ~[brigadier-1.0.17.jar:?] {}
    at net.minecraft.command.Commands.func_197052_a(Commands.java:271) ~[?:?] {re:classloading}
    at net.minecraft.command.Commands.func_197052_a(Commands.java:297) ~[?:?] {re:classloading}
    at net.minecraft.command.Commands.func_197051_a(Commands.java:265) ~[?:?] {re:classloading}
    at net.minecraft.server.management.PlayerList.func_187245_a(PlayerList.java:563) ~[?:?] {re:classloading}
    at net.minecraft.server.management.PlayerList.func_187243_f(PlayerList.java:457) ~[?:?] {re:classloading}
    at net.minecraft.server.management.PlayerList.func_72355_a(PlayerList.java:145) ~[?:?] {re:classloading}
    at net.minecraft.network.login.ServerLoginNetHandler.func_147326_c(ServerLoginNetHandler.java:116) ~[?:?] {re:classloading}
    at net.minecraft.network.login.ServerLoginNetHandler.func_73660_a(ServerLoginNetHandler.java:63) ~[?:?] {re:classloading}
    at net.minecraft.network.NetworkManager.func_74428_b(NetworkManager.java:224) ~[?:?] {re:classloading}
    at net.minecraft.network.NetworkSystem.func_151269_c(NetworkSystem.java:135) ~[?:?] {re:classloading}
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:864) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:782) ~[?:?] {re:classloading,pl:accesstransformer:B}
    at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:114) ~[?:?] {re:classloading,pl:runtimedistcleaner:A}
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:635) [?:?] {re:classloading,pl:accesstransformer:B}
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_241] {}
Caused by: java.lang.ClassNotFoundException: dan200.computercraft.shared.command.UserLevel$1
    at java.lang.ClassLoader.findClass(ClassLoader.java:523) ~[?:1.8.0_241] {}
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_241] {}
    at cpw.mods.modlauncher.TransformingClassLoader.loadClass(TransformingClassLoader.java:101) ~[modlauncher-5.0.0-milestone.4.jar:?] {}
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_241] {}
    ... 19 more

And the third time, I tried to load my previously saved world, but still reporting the same error as the second time.

SquidDev commented 4 years ago

Hrmr, this is very odd - I've double checked the jar, and all the files it thinls aren't there most definitely are.

luochen1990 commented 4 years ago

@SquidDev I downloaded a new jar, and compared the HASH to my current using, and they have the same hash (SHA1: 99FC8F3D41C842053560D912A327CC68D62B2365).

latest.log: https://pastebin.com/JxTMYJuh debug.log: https://pastebin.com/rw29Usi3

SquidDev commented 4 years ago

Thanks you very much for the logs! Yep, that's definitely the correct jar file too.

I recreated your mod pack, and tried to reproduce, but I'm afraid I've had no such luck. Everything seems to work fine on my end.

It might be worth trying to see if the vanilla launcher works (rather than HMCL), but I'd be very surprised if that was the problem here. Ughr, nothing about this makes sense :).

luochen1990 commented 4 years ago

@SquidDev Thanks for your patience, it is not surprising that you cannot reproduce it at once, I have played this games for several weeks on version 1.14.4 (also with cc-tweaked) and at the latest week I switched to 1.15.2 and this issue only occurs 3 or 4 times. every time it occurs I have to remove cc mod and execute /fml confirm on console to recover my world. And it seems occurs much more often on create mode (where I debug my turtle code) than survive mode.

luochen1990 commented 4 years ago

I tried a few more times to reproduce this problem, to locate this issue, I use git to track file changes, and find that:

luochen1990 commented 4 years ago

Now I can reproduce this issue, reproduce steps:

  1. create an empty world in creative mode.
  2. use 4 computer to build a gps station, and edit startup.lua as shell.run("gps", "host", x, y, z)
  3. use 1 computer as server to provide some service, and edit startup.lua as shell.run("wget", "run", "http://xxx.com/xxx.lua")

And re-enter the game for a few times to reproduce the issue.

It seems that simultaneously execute shell.run("gps", ...) and shell.run("wget", ..) in lua caused this issue, so now my workaround is, add sleep(1) before the server's (computers which is not gps-station) startup script, and it works well till now.

SquidDev commented 4 years ago

There's a bit of me which wonders if this is an instance of MinecraftForge/MinecraftForge#6655. There's definitely something odd going on in the class loader.

Assile commented 4 years ago

Now I can reproduce this issue, reproduce steps:

1. create an empty world in creative mode.

2. use 4 computer to build a gps station, and edit `startup.lua` as `shell.run("gps", "host", x, y, z)`

3. use 1 computer as server to provide some service, and edit `startup.lua` as `shell.run("wget", "run", "http://xxx.com/xxx.lua")`

And re-enter the game for a few times to reproduce the issue.

It seems that simultaneously execute shell.run("gps", ...) and shell.run("wget", ..) in lua caused this issue, so now my workaround is, add sleep(1) before the server's (computers which is not gps-station) startup script, and it works well till now.

I'm getting the same issue. Server crashes once I join with the following crash report: crash-2020-06-22_09.05.34-server.txt

I had 4 or 5 GPS hosts and a turtle with the following startup:

if fs.exists('tree_farm.lua') then
    fs.delete('tree_farm.lua')
end
shell.run('pastebin get LsB7RuPv tree_farm.lua')
shell.run('tree_farm')

I was able to fix the issue by adding a sleep(60) before the if statement. It seems delaying the get request allows for it to go through no issue. I had to first start the server up once with the startup removed/commented. Hope this helps pin it down!

luochen1990 commented 4 years ago

I think this issue should be reopened and remove the can not reproduce tag. @SquidDev

SquidDev commented 4 years ago

This is a Forge bug - from what I can tell it's a race condition in class loading. It's been reported on their repo, but there's sadly little I can do on my end.

SquidDev commented 4 years ago

For reference, https://github.com/MinecraftForge/MinecraftForge/issues/6719 is a more up-to-date version of the issue I linked above.

joshinils commented 4 years ago

this issue helped me, i have 1 turtle with the following startup file:

shell.run("rom/programs/delete.lua","gitPull.lua")
shell.run("rom/programs/http/wget.lua","https://raw.githubusercontent.com/joshinils/turtleCode/master/gitPull.lua")
shell.run("gitPull.lua")

print("attempting to call startupCustom.lua")
shell.run("startupCustom.lua")

renaming the startup.lua to .startup.lua let me join my server. loading the same world in singleplayer worked without any problem, saving and replacing the version on the server with it made no difference, only renaming the startup file