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 4740 - SDL_UpdateWindowSurface() failed for resized window
Summary: SDL_UpdateWindowSurface() failed for resized window
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: 2.0.9
Hardware: x86_64 Linux
: P2 major
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
: 4741 (view as bug list)
Depends on:
Blocks:
 
Reported: 2019-07-26 12:31 UTC by Koichi Yoshida
Modified: 2019-07-28 05:27 UTC (History)
1 user (show)

See Also:


Attachments
reproducible code (2.35 KB, text/plain)
2019-07-26 12:31 UTC, Koichi Yoshida
Details
reproducible code ver2 (3.80 KB, text/plain)
2019-07-28 05:07 UTC, Koichi Yoshida
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Koichi Yoshida 2019-07-26 12:31:39 UTC
Created attachment 3901 [details]
reproducible code

I found a problem that SDL_UpdateWindowSurface() failed for a window resized by SDL_SetWindowSize().
The window is created as "not full screen" and resizable. 

I have attached a reproducible code for the problem.

Tested environment:
	debian 10.0.0 amd64
	sdl2.0.9+dfsg1-1

How to reproduce the problem:
	gcc sdl2_UpdateWindowSurface_failed.c -lSDL2 && ./a.out
	In case of SDL_UpdateWindowSurface() failed, you can see an error message as follows.
	> SDL_UpdateWindowSurface failed: Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface
Comment 1 Alex Szpakowski 2019-07-27 17:19:57 UTC
*** Bug 4741 has been marked as a duplicate of this bug. ***
Comment 2 Alex Szpakowski 2019-07-27 17:22:39 UTC
The documentation says you need to call SDL_GetWindowSurface to obtain a valid surface, whenever the window is resized.
Comment 3 Koichi Yoshida 2019-07-28 02:24:44 UTC
Thank you for replying to my post.
I am sorry for duplicating.

After the window has been resized, the reproducible code calls SDL_GetWindowSurface ().
This is correct?
Comment 4 Koichi Yoshida 2019-07-28 05:07:14 UTC
Created attachment 3906 [details]
reproducible code ver2

TEST_CASE 0 shows the SIGSEGV case.
TEST_CASE 1~3 shows how to avoid the SIGSEGV.
Comment 5 Koichi Yoshida 2019-07-28 05:27:48 UTC
I found the problem looks like caused by timing.
If it sleeps 1 seconds after SDL_SetWindowSize(), it works correctly (TEST_CASE 2&3).
Also, if it cancels drawing when the surface width and height has not been changed correctly, it works correctly (TEST_CASE 1&3).