| Summary: | Windows: Crash when resizing Window since hg 333216331863 | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Gab <cesladrube> |
| Component: | video | Assignee: | David Ludwig <dll> |
| Status: | RESOLVED FIXED | QA Contact: | David Ludwig <dll> |
| Severity: | major | ||
| Priority: | P2 | CC: | baker.stephen.e, dll, hdp2, kai.sterker, sezeroz |
| Version: | HG 2.1 | ||
| Hardware: | x86 | ||
| OS: | Windows 8 | ||
| Attachments: | Should fix the issue | ||
Oh and this crashes with both Intel and Nvidia for me. Both have up-to-date drivers. Hi Gab, I'm unable to reproduce this on any of my Windows systems, and I'm not sure why. I created a window with SDL_WINDOW_RESIZABLE set, but was able to resize it without crashing, both with and without textures on it. Do you have any additional details on the system(s) you used to test this on? Any chance you could provide a sample program? Thanks for the update, I will recheck. Maybe got fixed in the meanwhile. I'm also unable to reproduce this using the revision you mentioned, https://hg.libsdl.org/SDL/rev/333216331863. Gab, might you have code for a small, sample program, which I could use to try reproducing this? Sorry, was my fault. I'm using the DirectX February 2010 SDK for compiling (since years) and just read on MSDN that they ship the DX SDK now with the Windows SDK... So removing that include fixed the crash. Got it. Thanks for the updated info! I'm sorry, have to reopen. I encountered the crash again and figured out the real cause now by stepping through SDL code.
The SDL_Texture must be created with a SDL_TEXTURE_FORMAT that is not supported (returns false for "IsSupportedFormat", for me this is SDL_PIXELFORMAT_ABGR8888)
This results in two textures being created (one in unsupported format, one in supported format) and only the supported one gets the "driverdata" field assigned (makes sense because only the supported one can be used by DirectX).
But D3D_Reset just loops over all textures and passes them to D3D_RecreateTexture which accesses driverdata but does not check for NULL.
The DirectX 11 backend has a NULL check in D3D11_DestroyTexture:
D3D11_TextureData *data = (D3D11_TextureData *)texture->driverdata;
if (!data) {
return;
}
Created attachment 2364 [details]
Should fix the issue
Proposed patch.
The alternative codepath through D3D_DestroyTexture already checks for NULL btw ;)
Confirmed that the patch fixed this crash for us. In our case the issue occurred when we were targeting larger than screen resolutions. *** Bug 3370 has been marked as a duplicate of this bug. *** Fix applied via https://hg.libsdl.org/SDL/rev/17e0ded12e6f Thanks for the fix, Gab! |
SDL_renderer_d3d.c line 844 if (!texture->texture) { return 0; } texture is NULL and crashes. How to reproduce: Create a Window with SDL_WINDOW_RESIZABLE and resize it. The first bad revision is 333216331863 https://hg.libsdl.org/SDL/rev/333216331863 "Use D3D9Ex when available This hopefully works around crashes in Intel D3D9 support in Windows 8.1." Stacktrace: Playerd.exe!D3D_RecreateTextureRep(IDirect3DDevice9 * device, D3D_TextureRep * texture, unsigned int format, int w, int h) Zeile 844 C Playerd.exe!D3D_RecreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) Zeile 969 C Playerd.exe!D3D_Reset(SDL_Renderer * renderer) Zeile 419 C Playerd.exe!D3D_ActivateRenderer(SDL_Renderer * renderer) Zeile 474 C Playerd.exe!D3D_RenderClear(SDL_Renderer * renderer) Zeile 1232 C Playerd.exe!SDL_RenderClear(SDL_Renderer * renderer) Zeile 1354 C Playerd.exe!SdlUi::UpdateDisplay() Zeile 543 C++ [...]