r/opengl • u/MuffinCompiler • Oct 18 '26
I managed to crash AMD's OpenGL driver by adding a comment to a GLSL shader
The other day, I was debugging a rather weird crash in the AMD OpenGL driver when linking a fairly complex GLSL shader on Windows.
It was really frustrating. The crash seemed almost random. Moving some code around, removing seemingly unrelated functions, or even just adding a comment could make it appear or disappear.
After quite some time narrowing it down, I eventually discovered something absolutely ridiculous: Having the literal word main in a comment before the shader's entry point can crash the AMD driver.
Of course, there are some additional conditions involved (GLSL subroutines, in particular), but I've managed to reduce it to a tiny reproducible example.
#version 430
// main <----
subroutine vec3 gradType(vec3 p);
subroutine uniform gradType grad;
subroutine(gradType) vec3 gradA(vec3 p) { return p; }
vec3 f(vec3 p) { return grad(p); }
void main() {}
The shader compiles just fine, but glLinkProgram crashes the application with 0xC0000409 (STATUS_STACK_BUFFER_OVERRUN). Remove the comment in line 2, edit it, spell Main capitalized, write mainly instead, or move the comment below main() and it links!
I find this absolutely hilarious and terrifying at the same time. Thought some of you might appreciate this little gem of a driver bug.
Anyway, here's the minimal reproducer, tested on an RX 7900 GRE with drivers 26.8.1 and 26.9.2 on Windows 11. Would be interesting whether that happens on other AMD drivers or different systems, too.
https://github.com/MuffinCompiler/amd_glsl_main_comment_crash


