SDL icon indicating copy to clipboard operation
SDL copied to clipboard

SDL3 GPU: SDL_AcquireGPUCommandBuffer : ignore_render_pass_texture_validation is left uninitialized

Open Sandalmoth opened this issue 6 months ago • 0 comments

I've been getting the following crashes

thread 1471842 panic: load of value 55, which is not valid for type 'bool'
/home/j/.cache/zig/p/sdl-0.2.4+3.2.16-7uIn9DPhfgH29yAIJqHLc69hNb4IW0q-AngtKCFoT92b/src/gpu/SDL_gpu.c:2060:71: 0x1aad5a3 in SDL_BindGPUFragmentSamplers_REAL (/home/j/.cache/zig/p/sdl-0.2.4+3.2.16-7uIn9DPhfgH29yAIJqHLc69hNb4IW0q-AngtKCFoT92b/src/gpu/SDL_gpu.c)
        if (!((CommandBufferCommonHeader*)RENDERPASS_COMMAND_BUFFER)->ignore_render_pass_texture_validation) {
  • I'm using the zig build-system port from https://github.com/castholm/SDL
  • It's running on the vulkan backend.
  • The value in "load of value 55" changes randomly with each crash
  • Crashes sometimes happen right away (usually second frame), sometimes after a short while, sometimes not for a long time.

After some digging, the invalid value (55 in this case) was set already when getting the command buffer from SDL_AcquireGPUCommandBuffer, and remained the same until the SDL_BindGPUFragementSamplers trigger the panic. It seems that ignore_render_pass_texture_validation is never set, and hence reads data from uninitialized memory. It is also not set in VULKAN_AcquireCommandBuffer, VULKAN_INTERNAL_GetInactiveCommandBufferFromPool or VULKAN_INTERNAL_AllocateCommandBuffer as far as I can tell.

Guess is that ignore_render_pass_texture_validation should be set inside of the if (device->debug_mode) {...} block in SDL_AcquireGPUCommandBuffer.

I don't know whether compiling through zig adds extra checks for non 0 or 1 values in bools that wouldn't normally be there, hence triggering the crash. However, I think it might still be an issue regardless, as it might result in debug validation not triggering as expected.

Sandalmoth avatar Jun 08 '25 08:06 Sandalmoth