| Summary: | [DX9] SEGFAULT in D3D_RecreateTexture | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Kai Sterker <kai.sterker> |
| Component: | render | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED DUPLICATE | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.0 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 8 | ||
While porting Adonthell to Windows, I encountered a segfault when switching screen modes, i.e. from desktop_fullscreen to windowed mode or fullscreen mode. Thread 1 received signal SIGSEGV, Segmentation fault. 0x000000006c7b170b in D3D_RecreateTextureRep (device=0xd82220, texture=0x0, format=390076419, w=96, h=24) at src/render/direct3d/SDL_render_d3d.c:886 886 if (texture->texture) { (gdb) bt #0 0x000000006c7b170b in D3D_RecreateTextureRep (device=0xd82220, texture=0x0, format=390076419, w=96, h=24) at src/render/direct3d/SDL_render_d3d.c:886 #1 0x000000006c7b1bff in D3D_RecreateTexture (renderer=0x32c1c0, texture=0x58be7e0) at src/render/direct3d/SDL_render_d3d.c:1007 #2 0x000000006c7b0773 in D3D_Reset (renderer=0x32c1c0) at src/render/direct3d/SDL_render_d3d.c:425 #3 0x000000006c7b098b in D3D_ActivateRenderer (renderer=0x32c1c0) at src/render/direct3d/SDL_render_d3d.c:486 #4 0x000000006c7b2adf in D3D_RenderClear (renderer=0x32c1c0) at src/render/direct3d/SDL_render_d3d.c:1296 #5 0x000000006c7aa470 in SDL_RenderClear_REAL (renderer=0x32c1c0) at src/render/SDL_render.c:1403 #6 0x000000006c7901a1 in SDL_RenderClear (a=0x32c1c0) Further debugging further shows: (gdb) up #1 0x000000006c7b1bff in D3D_RecreateTexture (renderer=0x32c1c0, texture=0x5e36360) at src/render/direct3d/SDL_render_d3d.c:1007 1007 if (D3D_RecreateTextureRep(data->device, &texturedata->texture, texture->format, texture->w, texture->h) < 0) { (gdb) print texturedata $1 = (D3D_TextureData *) 0x0 It's the SDL_Texture's driverdata that is NULL. But shouldn't this only be the case when the texture was actually deleted via SDL_DestroyTexture? However: (gdb) print *texture $3 = {magic = 0x6c8b3a71 <texture_magic>, format = 390076419, access = 1, w = 96, h = 24, modMode = 0, blendMode = SDL_BLENDMODE_NONE, r = 255 '▒', g = 255 '▒', b = 255 '▒', a = 255 '▒', renderer = 0x32c1c0, native = 0x5e36410, yuv = 0x0, pixels = 0x5e980c0, pitch = 288, locked_rect = {x = 0, y = 0, w = 96, h = 24}, driverdata = 0x0, prev = 0x0, next = 0x5e36410} That does not look deleted to me. Further testing shows that the SEGFAULT goes away if I add the following line to D3D_RecreateTexture: if (!texturedata) return 0; However, this only adresses the symptom, not the root cause. I may be wrong, but I don't think that half-created (or half-deleted) textures should ever show up in SDLs list of textures? For the record, this is under Windows 8.1 Pro in VirtualBox 5.0.22. Compiled SDL rev. b82c0f22d22a using mingw64. However, just to make sure I've also tried with the SDL2-devel-2.0.4-mingw.tar.gz package directly from the SDL website. Issue remains the same, albeit with a less useful stacktrace: hread 1 received signal SIGSEGV, Segmentation fault. 0x000000006c79976b in SDL_LogCritical () from C:\msys64\mingw64\usr\local\bin\SDL2.dll (gdb) bt #0 0x000000006c79976b in SDL_LogCritical () from C:\msys64\mingw64\usr\local\bin\SDL2.dll #1 0x000000006c799c6e in SDL_LogCritical () from C:\msys64\mingw64\usr\local\bin\SDL2.dll #2 0x000000006c79a267 in SDL_LogCritical () from C:\msys64\mingw64\usr\local\bin\SDL2.dll #3 0x000000000049c135 in screen::clear () at screen.h:140 The program in question can be found at http://cvs.savannah.gnu.org/viewvc/adonthell-0.3/?root=adonthell and the required game data at http://cvs.savannah.gnu.org/viewvc/wastesedge/?root=adonthell Just starting the game, then selecting Options and switching the screen mode will trigger the crash.