SDL_TEXTUREACCESS_STREAMING crashes when window size changes

Before I submit this to bugzilla, can anyone see anything I’ve done wrong here? Basically, it crashes when the window is resized if a streaming texture is created. Notice I haven’t even used the texture, but I am in a larger project and it all works until the window size changes. I can sort of fix the bug by destroying and recreating the streaming texture when I get a window size event, but it still crashes sometimes when the window loses focus and regains focus. This is all caused by the streaming texture attached to the renderer when a call to SDL_RenderPresent() is made (it causes a segfault). Only able to test this on Windows 10 and Windows 7 at present.

Code:
#include <SDL.h>

int main(int argc, char *argv[]) {
if(SDL_Init(SDL_INIT_EVERYTHING))
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, “Init fail”, SDL_GetError(), nullptr);
SDL_DisplayMode desktopMode;
if(SDL_GetDesktopDisplayMode(0, &desktopMode))
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, “Init fail”, SDL_GetError(), nullptr);
SDL_Window *screenWindow = SDL_CreateWindow(“Test”, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
desktopMode.w / 2, desktopMode.h / 2, SDL_WINDOW_RESIZABLE);
if(!screenWindow)
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, “Init fail”, SDL_GetError(), nullptr);
SDL_Renderer *renderer = SDL_CreateRenderer(screenWindow, -1, SDL_RENDERER_PRESENTVSYNC);
if(!renderer)
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, “Init fail”, SDL_GetError(), nullptr);
SDL_Texture *texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_BGR888, SDL_TEXTUREACCESS_STREAMING, 64, 64);
if(!texture)
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, “Init fail”, SDL_GetError(), nullptr);
SDL_Event event;
bool running = true;
bool fullscreen = false;
while(running) {
while(SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
running = false;
break;
case SDL_KEYDOWN:
switch(event.key.keysym.sym) {
case SDLK_ESCAPE:
running = false;
break;
case SDLK_SPACE:
fullscreen = !fullscreen;
SDL_SetWindowFullscreen(screenWindow, fullscreen?SDL_WINDOW_FULLSCREEN_DESKTOP:0);
break;
}
break;
}
}
if(SDL_SetRenderDrawColor(renderer, 0, 255, 0, SDL_ALPHA_OPAQUE))
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, “Error”, SDL_GetError(), nullptr);
if(SDL_RenderClear(renderer))
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, “Error”, SDL_GetError(), nullptr);
SDL_RenderPresent(renderer);
}
SDL_DestroyTexture(texture);
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(screenWindow);
SDL_Quit();
return 0;
}

ChliHug wrote:

This could be related to Bug 3147 (https://bugzilla.libsdl.org/show_bug.cgi?id=3147).

You’re right, it looks like it’s the same bug, thanks. I tested using various renderers and it only happens with direct3d.

I’m using Eclipse, so I can’t use the binary patch, unfortunately. Is this something that a new SDL2.dll should fix?