From 7963303a48b118f1348581b2ae22ca641ba6425e Mon Sep 17 00:00:00 2001 From: James Seibel Date: Fri, 13 Feb 2026 07:39:59 -0600 Subject: [PATCH] Finish all GL commands on Mac after buffer deletion Hopefully this will fix GL buffer SIGSEV and/or memory corruption. --- .../common/wrappers/minecraft/MinecraftGLWrapper.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftGLWrapper.java b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftGLWrapper.java index 3b7455a45..d543fcd0e 100644 --- a/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftGLWrapper.java +++ b/common/src/main/java/com/seibel/distanthorizons/common/wrappers/minecraft/MinecraftGLWrapper.java @@ -25,6 +25,7 @@ import com.mojang.blaze3d.platform.GlStateManager; import com.mojang.blaze3d.opengl.GlStateManager; #endif +import com.seibel.distanthorizons.core.jar.EPlatform; import com.seibel.distanthorizons.core.logging.DhLoggerBuilder; import com.seibel.distanthorizons.core.wrapperInterfaces.minecraft.IMinecraftGLWrapper; @@ -190,6 +191,16 @@ public class MinecraftGLWrapper implements IMinecraftGLWrapper { GL32.glDeleteBuffers(buffer); + // attempt to fix a bug with Mac where de-allocated buffers + // are still being used, causing a SIGSEGV native crash + // and/or corrupting native memory + if (EPlatform.get() == EPlatform.MACOS) + { + // force the delete buffer (and any other in-flight) GL + // commands to finish before continuing + GL32.glFinish(); + } + // MC's implementation has a bug where it will throw: // GL_INVALID_OPERATION in glBufferData(immutable) // when attempting to delete Storage Buffers