raysan5 / raylib

A simple and easy-to-use library to enjoy videogames programming
http://www.raylib.com
zlib License
22.66k stars 2.28k forks source link

[rmodels] Loading various models causes MSVC Heapcheck to fail on unload #4349

Closed HarryDC closed 1 month ago

HarryDC commented 1 month ago

Please, before submitting a new issue verify and check:

Issue description

Using Microsoft Visual Studio and a debug build, when i load various models from the Kenney Hex set in both .obj and .glb format, runtime issues a warning about a Heap Corruption at the UnloadModel() call, the same models work fine using v5.0. This even happens when just LoadModel()/UnloadModel() is used without drawing.

After using git bisect from the current main as of today back to v5.0 the offending commit was labeled as 86ead962633f5ee819829550dc8acdd9cd07f667 (Optional GPU Skinning)

Environment

Windows 11, MSVC

Issue Screenshot

image

image

Code Example

... model = LoadModel("resources/obj/dirt.obj"); UnloadModel(model); ...

HarryDC commented 1 month ago

dirt.zip

This is the model i used to check, the issue is most likely a MAX_MESH_VERTEX_BUFFERS definition in config.h line 231 that is 7, whereas the value needs to be 9 as defined in line 123 in rmodels.c

stevegwh commented 1 month ago

Can confirm this seems to occur on macOS with clang, too. I checked out the "Optional GPU Skinning" (86ead96) commit today and encountered the same error with "MAX_MESH_VERTEX_BUFFERS" likely being the culprit. Changing "MAX_MESH_VERTEX_BUFFERS" to "9" in config.h as suggested stopped the error.

raysan5 commented 1 month ago

@stevegwh Thanks for finding the issue, it should be fixed now.