Minecraft can crash when failing to connect to a server
The bug
When you start to connect to a server but it fails to connect for whatever reason, there is a chance that Minecraft might crash.
Code analysis
Based on 1.11 decompiled using MCP 9.35 rc1
The method net.minecraft.client.multiplayer.GuiConnecting.connect(String, int) creates a new thread to connect to a server. When the connection is closed a new net.minecraft.client.gui.GuiDisconnected is shown. The problem is that this class does not have a constructor and therefor the mc field storing the reference to the Minecraft instance remains null. This GUI is then displayed using the method net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) which would call the method net.minecraft.client.gui.GuiScreen.setWorldAndResolution(Minecraft, int, int) and set a value for the field. The problem here is that as this happens in a seperate thread the main thread might try to render this GUI already while the mc field is still null. This causes this crash then.
[Mod] Pokechu22 suggests in general to not directly call the Minecraft.displayGuiScreen(GuiScreen) method from other threads but instead create a Callable for it then call the method Minecraft.addScheduledTask(Callable<V> callableToSchedule) with it as argument.
How to reproduce (modded version)
Note: This can be reproduced with an unmodded version of Minecraft but there it will not always happen, whereas with this modification it should be always reproducible.
You can change the method net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) to sleep for some seconds before the method net.minecraft.client.gui.GuiScreen.setWorldAndResolution(Minecraft, int, int) of the GUI is called when this GUI is an instance of GuiDisconnected. Then Minecraft should crash if you try to connect to a server with a non-existant host or to an offline server.
To reproduce (jdb)
Similarly, adding a breakpoint in displayGuiScreen after assigning the field but before setWorldAndResolution can be used to trigger this same issue. As of 1.13-pre5, this is cep:712, so attaching jdb to a running minecraft and then entering stop at ceg:712 will let you reproduce this issue. Note that you will need to resume each time a new GUI has opened, so it may make sense to set the breakpoint only after entering the multiplayer screen. Once the breakpoint has been hit in a "Server Connector" thread, wait a few seconds and then enter resume one more time and the game will crash. (You may have to enter resume one more time).
Stacktrace
To make sure this report can be found when searching for the stacktrace
Description: Rendering screen java.lang.NullPointerException: Rendering screen at bho.d_(SourceFile:437) at bho.c(SourceFile:433) at bhc.a(SourceFile:44) at bqe.a(SourceFile:1078) at bes.av(SourceFile:993) at bes.a(SourceFile:398) at net.minecraft.client.main.Main.main(SourceFile:124)
Created Issue:
Minecraft can crash when failing to connect to a server
The bug
When you start to connect to a server but it fails to connect for whatever reason, there is a chance that Minecraft might crash.
Code analysis
Based on 1.11 decompiled using MCP 9.35 rc1
The method net.minecraft.client.multiplayer.GuiConnecting.connect(String, int) creates a new thread to connect to a server. When the connection is closed a new net.minecraft.client.gui.GuiDisconnected is shown. The problem is that this class does not have a constructor and therefor the mc field storing the reference to the Minecraft instance remains null. This GUI is then displayed using the method net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) which would call the method net.minecraft.client.gui.GuiScreen.setWorldAndResolution(Minecraft, int, int) and set a value for the field. The problem here is that as this happens in a seperate thread the main thread might try to render this GUI already while the mc field is still null. This causes this crash then.
[Mod] Pokechu22 suggests in general to not directly call the Minecraft.displayGuiScreen(GuiScreen) method from other threads but instead create a thread for it and enque it for the main thread.
How to reproduce (modded version)
Note: This can be reproduced with an unmodded version of Minecraft but there it will not always happen, whereas with this modification it should be always reproducible.
You can change the method net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) to sleep for some seconds before the method net.minecraft.client.gui.GuiScreen.setWorldAndResolution(Minecraft, int, int) of the GUI is called when this GUI is an instance of GuiDisconnected. Then Minecraft should crash if you try to connect to a server with a non-existant host or to an offline server.
The bug
When you start to connect to a server but it fails to connect for whatever reason, there is a chance that Minecraft might crash.
Code analysis
Based on 1.11 decompiled using MCP 9.35 rc1
The method net.minecraft.client.multiplayer.GuiConnecting.connect(String, int) creates a new thread to connect to a server. When the connection is closed a new net.minecraft.client.gui.GuiDisconnected is shown. The problem is that this class does not have a constructor and therefor the mc field storing the reference to the Minecraft instance remains null. This GUI is then displayed using the method net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) which would call the method net.minecraft.client.gui.GuiScreen.setWorldAndResolution(Minecraft, int, int) and set a value for the field. The problem here is that as this happens in a seperate thread the main thread might try to render this GUI already while the mc field is still null. This causes this crash then.
[Mod] Pokechu22 suggests in general to not directly call the Minecraft.displayGuiScreen(GuiScreen) method from other threads but instead create a thread for it and enque it for the main thread.
How to reproduce (modded version)
Note: This can be reproduced with an unmodded version of Minecraft but there it will not always happen, whereas with this modification it should be always reproducible.
You can change the method net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) to sleep for some seconds before the method net.minecraft.client.gui.GuiScreen.setWorldAndResolution(Minecraft, int, int) of the GUI is called when this GUI is an instance of GuiDisconnected. Then Minecraft should crash if you try to connect to a server with a non-existant host or to an offline server.
Stacktrace
To make sure this report can be found when searching for the stacktrace
1.11.2Description: Rendering screen java.lang.NullPointerException: Rendering screen at bho.d_(SourceFile:437) at bho.c(SourceFile:433) at bhc.a(SourceFile:44) at bqe.a(SourceFile:1078) at bes.av(SourceFile:993) at bes.a(SourceFile:398) at net.minecraft.client.main.Main.main(SourceFile:124)
The bug
When you start to connect to a server but it fails to connect for whatever reason, there is a chance that Minecraft might crash.
Code analysis
Based on 1.11 decompiled using MCP 9.35 rc1
The method net.minecraft.client.multiplayer.GuiConnecting.connect(String, int) creates a new thread to connect to a server. When the connection is closed a new net.minecraft.client.gui.GuiDisconnected is shown. The problem is that this class does not have a constructor and therefor the mc field storing the reference to the Minecraft instance remains null. This GUI is then displayed using the method net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) which would call the method net.minecraft.client.gui.GuiScreen.setWorldAndResolution(Minecraft, int, int) and set a value for the field. The problem here is that as this happens in a seperate thread the main thread might try to render this GUI already while the mc field is still null. This causes this crash then.
[Mod] Pokechu22 suggests in general to not directly call the Minecraft.displayGuiScreen(GuiScreen) method from other threads but instead create a
thread for it and enque it for the main thread.How to reproduce (modded version)
Note: This can be reproduced with an unmodded version of Minecraft but there it will not always happen, whereas with this modification it should be always reproducible.
You can change the method net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) to sleep for some seconds before the method net.minecraft.client.gui.GuiScreen.setWorldAndResolution(Minecraft, int, int) of the GUI is called when this GUI is an instance of GuiDisconnected. Then Minecraft should crash if you try to connect to a server with a non-existant host or to an offline server.
Stacktrace
To make sure this report can be found when searching for the stacktrace
1.11.2Description: Rendering screen java.lang.NullPointerException: Rendering screen at bho.d_(SourceFile:437) at bho.c(SourceFile:433) at bhc.a(SourceFile:44) at bqe.a(SourceFile:1078) at bes.av(SourceFile:993) at bes.a(SourceFile:398) at net.minecraft.client.main.Main.main(SourceFile:124)The bug
When you start to connect to a server but it fails to connect for whatever reason, there is a chance that Minecraft might crash.
Code analysis
Based on 1.11 decompiled using MCP 9.35 rc1
The method net.minecraft.client.multiplayer.GuiConnecting.connect(String, int) creates a new thread to connect to a server. When the connection is closed a new net.minecraft.client.gui.GuiDisconnected is shown. The problem is that this class does not have a constructor and therefor the mc field storing the reference to the Minecraft instance remains null. This GUI is then displayed using the method net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) which would call the method net.minecraft.client.gui.GuiScreen.setWorldAndResolution(Minecraft, int, int) and set a value for the field. The problem here is that as this happens in a seperate thread the main thread might try to render this GUI already while the mc field is still null. This causes this crash then.
[Mod] Pokechu22 suggests in general to not directly call the Minecraft.displayGuiScreen(GuiScreen) method from other threads but instead create a Callable for it then call the method Minecraft.addScheduledTask(Callable<V> callableToSchedule) with it as argument.
How to reproduce (modded version)
Note: This can be reproduced with an unmodded version of Minecraft but there it will not always happen, whereas with this modification it should be always reproducible.
You can change the method net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) to sleep for some seconds before the method net.minecraft.client.gui.GuiScreen.setWorldAndResolution(Minecraft, int, int) of the GUI is called when this GUI is an instance of GuiDisconnected. Then Minecraft should crash if you try to connect to a server with a non-existant host or to an offline server.
Stacktrace
To make sure this report can be found when searching for the stacktrace
1.11.2Description: Rendering screen java.lang.NullPointerException: Rendering screen at bho.d_(SourceFile:437) at bho.c(SourceFile:433) at bhc.a(SourceFile:44) at bqe.a(SourceFile:1078) at bes.av(SourceFile:993) at bes.a(SourceFile:398) at net.minecraft.client.main.Main.main(SourceFile:124)
is duplicated by
is duplicated by
relates to
The bug
When you start to connect to a server but it fails to connect for whatever reason, there is a chance that Minecraft might crash.
Code analysis
Based on 1.11 decompiled using MCP 9.35 rc1
The method net.minecraft.client.multiplayer.GuiConnecting.connect(String, int) creates a new thread to connect to a server. When the connection is closed a new net.minecraft.client.gui.GuiDisconnected is shown. The problem is that this class does not have a constructor and therefor the mc field storing the reference to the Minecraft instance remains null. This GUI is then displayed using the method net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) which would call the method net.minecraft.client.gui.GuiScreen.setWorldAndResolution(Minecraft, int, int) and set a value for the field. The problem here is that as this happens in a seperate thread the main thread might try to render this GUI already while the mc field is still null. This causes this crash then.
[Mod] Pokechu22 suggests in general to not directly call the Minecraft.displayGuiScreen(GuiScreen) method from other threads but instead create a Callable for it then call the method Minecraft.addScheduledTask(Callable<V> callableToSchedule) with it as argument.
How to reproduce (modded version)
Note: This can be reproduced with an unmodded version of Minecraft but there it will not always happen, whereas with this modification it should be always reproducible.
You can change the method net.minecraft.client.Minecraft.displayGuiScreen(GuiScreen) to sleep for some seconds before the method net.minecraft.client.gui.GuiScreen.setWorldAndResolution(Minecraft, int, int) of the GUI is called when this GUI is an instance of GuiDisconnected. Then Minecraft should crash if you try to connect to a server with a non-existant host or to an offline server.
To reproduce (jdb)
Similarly, adding a breakpoint in displayGuiScreen after assigning the field but before setWorldAndResolution can be used to trigger this same issue. As of 1.13-pre5, this is cep:712, so attaching jdb to a running minecraft and then entering stop at ceg:712 will let you reproduce this issue. Note that you will need to resume each time a new GUI has opened, so it may make sense to set the breakpoint only after entering the multiplayer screen. Once the breakpoint has been hit in a "Server Connector" thread, wait a few seconds and then enter resume one more time and the game will crash. (You may have to enter resume one more time).
Stacktrace
To make sure this report can be found when searching for the stacktrace
1.11.2Description: Rendering screen java.lang.NullPointerException: Rendering screen at bho.d_(SourceFile:437) at bho.c(SourceFile:433) at bhc.a(SourceFile:44) at bqe.a(SourceFile:1078) at bes.av(SourceFile:993) at bes.a(SourceFile:398) at net.minecraft.client.main.Main.main(SourceFile:124)
Thank you for your report!
However, this issue is a Duplicate of MC-111755.
It has been linked to this report. If you have additional information, please add it to that report.
Please search before reporting. In this case you probably wouldn't have been able to find the other report (I only recognized it because the crash report looked similar and I'd seen MC-111755 before), but for other issues it is worth searching.
Quick Links:
📓 Issue Guidelines – 💬 Community Support – 📧 Customer Support – 📖 Game Wiki
This is basically the same issue as MC-111755: displayGuiScreen is called from the wrong thread when failing to connect to the server. However, my guess is that the newly added font code is now causing GL code to be called in initGui, making a crash happen 100% of the time (instead of requiring a race condition).
The fix for this is the same as the fix for that: schedule a task to display the GUI (i.e. replace mc.displayGuiScreen(new GuiDisconnected(...)) with mc.addScheduledTask(() -> mc.displayGuiScreen(new GuiDisconnected(...)). It would also make sense to add a check for wrong-thread calls in displayGuiScreen to catch similar mistakes.