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 4386 - Cocoa : ScheduleContextUpdates does not check given parameter ONLY with SDL_WINDOW_FULLSCREEN_DESKTOP flags
Summary: Cocoa : ScheduleContextUpdates does not check given parameter ONLY with SDL_W...
Status: RESOLVED DUPLICATE of bug 4394
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: 2.0.9
Hardware: x86 macOS 10.13
: P2 major
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-15 14:29 UTC by jeroen.clarysse
Modified: 2018-11-20 05:32 UTC (History)
1 user (show)

See Also:


Attachments
ScheduleContextUpdates crashes for SDL_WINDOW_FULLSCREEN_DESKTOP windows (954.80 KB, application/zip)
2018-11-15 14:29 UTC, jeroen.clarysse
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jeroen.clarysse 2018-11-15 14:29:54 UTC
Created attachment 3495 [details]
ScheduleContextUpdates crashes for SDL_WINDOW_FULLSCREEN_DESKTOP windows

the function 

    ScheduleContextUpdates(SDL_WindowData *data)

in the file SDL_cocoawindow.m does NOT check if data is valid. My application crashes upon exiting with a EXC_BAD_ACCESS exception

this is on OSX 10.14 (which is not selectable in bugzilla...)

in attach is a simple application that just does this :


	SDL_Renderer* renderer;
	SDL_Init( SDL_INIT_EVERYTHING );
	//	TTF_Init();
	
	SDL_Window *window;        // Declare a pointer to an SDL_Window
	
	int dialog_w = 640;
	int dialog_h = 480;
	
	window = SDL_CreateWindow("Keystroke detection",SDL_WINDOWPOS_UNDEFINED,SDL_WINDOWPOS_UNDEFINED,dialog_w,dialog_h,SDL_WINDOW_FULLSCREEN_DESKTOP|SDL_WINDOW_SHOWN|SDL_WINDOW_BORDERLESS);
	renderer = SDL_CreateRenderer(window, -1, 0);
	
	
	SDL_Delay(2500);
	SDL_DestroyRenderer(renderer);
	SDL_Delay(2500);
	SDL_DestroyWindow(window);
	SDL_Delay(2500);
	SDL_Quit();


note : this ONLY happens if the window was created with SDL_WINDOW_FULLSCREEN_DESKTOP flags !!!


fix is simple : add these lines as first 2 lines in ScheduleContextUpdates implementation
    
	if (!data || data->window == NULL || data->nswindow == nil)
		return;
Comment 1 Sam Lantinga 2018-11-20 04:17:28 UTC
Ryan, the fix is pretty straightforward, but can you look and see what's happening here?
Comment 2 Sam Lantinga 2018-11-20 05:32:35 UTC
Nevermind, Cameron Gutman provided a good description of how this can happen.

*** This bug has been marked as a duplicate of bug 4394 ***