A resource pack shader whose #include directive references itself causes a native crash inside shaderc.dll. The JVM exits via EXCEPTION_UNCAUGHT_CXX_EXCEPTION (0xe06d7363) propagating out of the shaderc native library.
This regression was introduced in 26.3 snapshot 5, which replaced the java sidecom.mojang.blaze3d.preprocessor.GlslPreprocessor used in snapshots 1 to 4 with the native shaderc include callback at com.mojang.renderpearl.frontend.shaders.GlslCompiler.
Unlike the previous java side implementation, the native shaderc include callback has no recursion depth limit. As a result, a self referencing include causes unbounded native recursion, eventually exhausting the C++ stack and terminating the process.
Steps to Reproduce
Enable the attached resource pack and load a world.
The game softlocks for several seconds while shaderc burns CPU on the recursion.
The JVM eventually terminates.
When the shader’s compile path pulls in oit_common.glsl (it is included by core/oit.glsl, core/oit_transmittance.fsh, core/oit_accumulate.fsh, and core/oit_depth_sample.fsh), the native shaderc library recurses without limit.
Root Cause
In com.mojang.renderpearl.frontend.shaders.GlslCompiler, the include callback passes the include request straight to shaderc's native resolver with no java side recursion guard:
public GlslCompiler(final boolean isZeroToOne, final boolean shaderDrawParameters) {
// ...
this.includeResolver = ShadercIncludeResolve.create((requested_source, ...) -> {
String requestedShader = MemoryUtil.memUTF8(requested_source);
Identifier id = Identifier.tryParse(requestedShader);
if (id == null) return this.malformedIdResult;
ShaderSource.CachedIncludeSource shaderContents = shaderSource.getInclude(id);
return shaderContents == null ? this.missingIncludeResult : shaderContents;
});
// ...
}Minecraft.triggerResourcePackRecovery would normally catch java exceptions and call clearResourcePacksOnError, which disables the offending resource pack and reloads. Because the crash occurs in native code outside the JVM exception system, triggerResourcePackRecovery never fires. The process dies.
Additionally, this relates to MC-310382
Thank you for helping us improve Minecraft! We saved your files: