LWJGL / lwjgl3

LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan, bgfx), audio (OpenAL, Opus), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR, OpenXR) applications.
https://www.lwjgl.org
BSD 3-Clause "New" or "Revised" License
4.75k stars 635 forks source link

[Suggestion]: use canary values to catch memory out of boundary errors when the debug option is enabled #983

Open HamiltonHuaji opened 4 months ago

HamiltonHuaji commented 4 months ago

Description

In debug mode, place canary values before and after the memory blocks allocated by functions like memAlloc or MemoryStack.stackPush. After native calls, check if these values have been accidentally modified, and throw an exception to warn the developer about the memory boundary issue and provide information such as the line of code where the memory block was allocated.