We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 3196 - Segmentation fault when using window surface and accelerated renderer
Summary: Segmentation fault when using window surface and accelerated renderer
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: render (show other bugs)
Version: 2.0.2
Hardware: x86_64 Linux
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-03 18:47 UTC by Ferdinand Vesely
Modified: 2016-01-02 18:20 UTC (History)
2 users (show)

See Also:


Attachments
Test program (586 bytes, text/x-csrc)
2015-12-03 18:47 UTC, Ferdinand Vesely
Details
GDB backtrace leading to SDL_InvalidateMap (988 bytes, text/plain)
2015-12-03 18:49 UTC, Ferdinand Vesely
Details
GDB backtrace leading to SDL_FreePalette_REAL (1.01 KB, text/plain)
2015-12-03 18:50 UTC, Ferdinand Vesely
Details
patch to fix a crash (445 bytes, patch)
2015-12-04 20:38 UTC, Philipp Wiesemann
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ferdinand Vesely 2015-12-03 18:47:43 UTC
Created attachment 2322 [details]
Test program

I get a segmentation fault (occasionally an invalid pointer error from free()) when accessing the window surface using SDL_GetWindowSurface and then creating a renderer using SDL_CreateRenderer with SDL_RENDERER_ACCELERATED on the same window. The segfault happens when SDL_DestroyWindow is called and the backtrace leads to SDL_InvalidateMap and sometimes to SDL_FreePalette_REAL.

I couldn't trigger the segfault it with SDL_RENDERER_SOFTWARE. Also if I remove the call to SDL_GetWindowSurface it works fine. Drawing using the accelerated renderer also works without a problem.

The test program is attached.
Comment 1 Ferdinand Vesely 2015-12-03 18:49:13 UTC
Created attachment 2323 [details]
GDB backtrace leading to SDL_InvalidateMap
Comment 2 Ferdinand Vesely 2015-12-03 18:50:55 UTC
Created attachment 2324 [details]
GDB backtrace leading to SDL_FreePalette_REAL
Comment 3 Philipp Wiesemann 2015-12-04 20:38:06 UTC
Created attachment 2328 [details]
patch to fix a crash

The attached patch seems to fix a crash (but maybe only by coincidence and not fixing the actual fault).
Comment 4 Ryan C. Gordon 2015-12-29 05:53:08 UTC
(In reply to Philipp Wiesemann from comment #3)
> Created attachment 2328 [details]
> patch to fix a crash
> 
> The attached patch seems to fix a crash (but maybe only by coincidence and
> not fixing the actual fault).

This looks like a good fix (whether it resolves this bug or not), so feel free to push that change if you want, Phillipp.

--ryan.
Comment 5 Philipp Wiesemann 2015-12-29 18:22:47 UTC
The first patch was applied here:
https://hg.libsdl.org/SDL/rev/08d023f75d78
Comment 6 Sam Lantinga 2016-01-02 18:20:53 UTC
Thanks!