Mojira Archive
MC-223021

glShaderSource fails on some AMD drivers resulting in a crash on 1.17

AMD drivers ship with a bug that causes a crash on some glShaderSource calls. This causes the game to crash randomly when loading a world and almost every time when reloading resource packs when graphics settings are set to fabulous. A crash dump is attached to this issue

This issue isn't directly Minecraft's fault, but the bug has been present for almost a year and so a workaround would be ideal.

This can be "fixed" by replacing the GL20.glShaderSource call in com.mojang.blaze3d.platform.GlStateManager.glShaderSource with

final MemoryStack stack = MemoryStack.stackGet();
final int stackPointer = stack.getPointer();

try {
   StringBuilder builder = new StringBuilder();
   for (String string : strings) {
      builder.append(string);
   }
   final ByteBuffer sourceBuffer = MemoryUtil.memUTF8(builder.toString(), true);
   final PointerBuffer pointers = stack.mallocPointer(1);
   pointers.put(sourceBuffer);
   GL20C.nglShaderSource(shader, 1, pointers.address0(), 0);
   org.lwjgl.system.APIUtil.apiArrayFree(pointers.address0(), 1);
} finally {
   stack.setPointer(stackPointer);
}

Fixed

BalintCsala

[Mojang] Felix Jones

2021-04-12, 12:31 PM

2021-05-26, 05:03 PM

2021-05-26, 05:03 PM

2

4

Plausible

Very Important

Crash, Rendering

21w14a

1.17 Pre-release 1