Paper icon indicating copy to clipboard operation
Paper copied to clipboard

Server crashed with unexcepted stacktrace if address/port in used

Open Ghost-chu opened this issue 2 years ago • 8 comments

Stack trace

https://paste.gg/p/anonymous/e140028727d94fccbc01c15f9d1daec4

Plugin and Datapack List

Clean install without any plugin or datapack or worlds.

Actions to reproduce (if known)

Start a clean Minecraft server instance on 25565. Start another clean Minecraft server instance on 25565. You got it!

Paper version

Server crashed before accept command.

#142 - Paper 1.19.2 https://github.com/PaperMC/Paper/commit/ef0e5a642d33ac62f070c45a61cb42647b2744cd

Other

In old Paper builds, Paper will exit without create a crash-report.

After update to latest (#142 - ef0e5a) build, paper will create a exception and crash-report before exit.

Ghost-chu avatar Sep 15 '22 13:09 Ghost-chu

Something on your system is already using the port your server is attempting to run on. The server obviously cannot start.

lynxplay avatar Sep 15 '22 13:09 lynxplay

Something on your system is already using the port your server is attempting to run on. The server obviously cannot start.

No, see the other section:

In old Paper builds, Paper will exit without create a crash-report.

After update to latest (https://github.com/PaperMC/Paper/issues/142 - ef0e5a) build, paper will create a exception and crash-report before exit.

Ghost-chu avatar Sep 15 '22 13:09 Ghost-chu

So this issue is about the stacktrace created when the server is shutting down due to a port already bound ?

lynxplay avatar Sep 15 '22 13:09 lynxplay

So this issue is about the stacktrace created when the server is shutting down due to a port already bound ?

yes

Ghost-chu avatar Sep 15 '22 13:09 Ghost-chu

updated title for better explanation

Ghost-chu avatar Sep 15 '22 13:09 Ghost-chu

Thank you.

lynxplay avatar Sep 15 '22 13:09 lynxplay

I'll reopen this for now, tho at least in my opinion this has a very low priority. The logs clearly state the issue here. If you feel like it, you can submit a PR to fix this issue (a rather straight forward null check for that matter), otherwise I'll leave the issue on low priority for someone to potentially fix in the future.

Sorry again for not completely understanding your exact issue here, the title change certainly specified your issue better.

lynxplay avatar Sep 15 '22 13:09 lynxplay

This has been the case for a long while, the only difference now is that vanilla moved their crash reporting logic somewhere in 1.19.x that now it will generate a crash report as opposed to just being logged; The handling of the bind failure should probably be improved, but, not particularly a bug to be cared about

electronicboy avatar Sep 15 '22 14:09 electronicboy

I decided to fix this, but I'm not sure it should be fixed? There are actually two exceptions, both of which get logged. Fixing one with a null check is easy enough, but the IllegalStateException is still logged.

In MinecraftServer.java:

    protected void runServer() {
        try {
            long serverStartTime = Util.getNanos(); // Paper
            if (!this.initServer()) {
                throw new IllegalStateException("Failed to initialize server");
            }

Obviously this can be fixed with

            if (throwable instanceof IllegalStateException) {
                return;
            }

in the catch statement before the crash report is generated, but that seems like it could catch things that ought to be logged.

I realize this is a very insignificant bug and I'm probably overthinking this, but I'm trying to get the hang of the code base. Going for low hanging fruit seems like a good start.

Remynfv avatar Sep 29 '22 06:09 Remynfv

Since this is a vanilla change, the only issue to care about is the NPE not the illegal state exception.

Lulu13022002 avatar Sep 29 '22 10:09 Lulu13022002

The general headache is that now that mojang is harder at generating the crash report, people run towards that rather than just looking at the logs. Part of the Q here is do we try to move the more obvious error so that it shows up inside of the crash report

electronicboy avatar Sep 29 '22 10:09 electronicboy

Can no longer reproduce the NPE happening on 1.20.4

Warriorrrr avatar Feb 10 '24 09:02 Warriorrrr