chrisdill / raylib-cs

C# bindings for raylib, a simple and easy-to-use library to learn videogames programming

Home Page:http://www.raylib.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

UnloadMesh causes double free or corruption on Debian Linux

pkhead opened this issue · comments

Issue description

Calling Raylib.UnloadMesh on my Debian Linux system causes a "double free or corruption" error, forcefully aborting the program.

What follows is the terminal output of a simple Raylib-cs program that calls UnloadMesh(ref mesh).

INFO: Initializing raylib 5.0
INFO: Platform backend: DESKTOP (GLFW)
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
INFO: DISPLAY: Device initialized successfully
INFO:     > Display size: 1920 x 1080
INFO:     > Screen size:  800 x 450
INFO:     > Render size:  800 x 450
INFO:     > Viewport offsets: 0, 0
INFO: GLAD: OpenGL extensions loaded successfully
INFO: GL: Supported extensions count: 233
INFO: GL: OpenGL device information:
INFO:     > Vendor:   AMD
INFO:     > Renderer: AMD Radeon Vega 8 Graphics (raven, LLVM 15.0.6, DRM 3.49, 6.1.0-17-amd64)
INFO:     > Version:  4.6 (Core Profile) Mesa 22.3.6
INFO:     > GLSL:     4.60
INFO: GL: VAO extension detected, VAO functions loaded successfully
INFO: GL: NPOT textures extension detected, full NPOT textures supported
INFO: GL: DXT compressed textures supported
INFO: GL: ETC2/EAC compressed textures supported
INFO: PLATFORM: DESKTOP (GLFW): Initialized successfully
INFO: TEXTURE: [ID 1] Texture loaded successfully (1x1 | R8G8B8A8 | 1 mipmaps)
INFO: TEXTURE: [ID 1] Default texture loaded successfully
INFO: SHADER: [ID 1] Vertex shader compiled successfully
INFO: SHADER: [ID 2] Fragment shader compiled successfully
INFO: SHADER: [ID 3] Program shader loaded successfully
INFO: SHADER: [ID 3] Default shader loaded successfully
INFO: RLGL: Render batch vertex buffers loaded successfully in RAM (CPU)
INFO: RLGL: Render batch vertex buffers loaded successfully in VRAM (GPU)
INFO: RLGL: Default OpenGL state initialized successfully
INFO: TEXTURE: [ID 2] Texture loaded successfully (128x128 | GRAY_ALPHA | 1 mipmaps)
INFO: FONT: Default font loaded successfully (224 glyphs)
INFO: VAO: [ID 2] Mesh uploaded successfully to VRAM (GPU)
INFO: VAO: [ID -1165953456] Unloaded vertex array data from VRAM (GPU)
double free or corruption (out)
Aborted

I have also tested it using UnloadMesh(&mesh). It creates a segmentation fault instead.

Environment

OS: Debian 6.1.69-1, x86_64

OpenGL device information:

  • Vendor: AMD
  • Renderer: AMD Radeon Vega 8 Graphics (raven, LLVM 15.0.6, DRM 3.49, 6.1.0-17-amd64)
  • Version: 4.6 (Core Profile) Mesa 22.3.6
  • GLSL: 4.60

.NET:

  • Version: 8.0.204
  • Raylib-cs: version 6.0.0

Code example

namespace RaylibTest;
using Raylib_cs;

class RaylibTest
{
    static void Main()
    {
        const int screenWidth = 800;
        const int screenHeight = 450;

        Raylib.InitWindow(screenWidth, screenHeight, "raylib mesh unload test");

        Mesh mesh = Raylib.GenMeshPlane(10.0f, 10.0f, 1, 1);
        Raylib.UnloadMesh(ref mesh);
        Raylib.CloseWindow();
    }
}

I have a made an equivalent program in C, which unlike the C# version, runs without error. I linked it against "raylib-5.0_linux_amd64.tar.gz". from Raylib's GitHub releases page.

#include <raylib.h>

int main() {
    const int screenWidth = 800;
    const int screenHeight = 450;

    InitWindow(screenWidth, screenHeight, "raylib mesh unload test");

    Mesh mesh = GenMeshPlane(10.0f, 10.0f, 1, 1);
    UnloadMesh(mesh);
    CloseWindow();
}