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 1365 - SDL_CreateWindow tend to crash when SDL is loaded multiple times
Summary: SDL_CreateWindow tend to crash when SDL is loaded multiple times
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: video (show other bugs)
Version: HG 2.0
Hardware: x86 Mac OS X 10.7
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-01-08 07:51 UTC by jianann87
Modified: 2012-01-13 22:39 UTC (History)
0 users

See Also:


Attachments
simple app that can reproduce the crash (2.20 KB, application/octet-stream)
2012-01-13 06:56 UTC, jianann87
Details

Note You need to log in before you can comment on or make changes to this bug.
Description jianann87 2012-01-08 07:51:39 UTC
When SDL is loaded and close multiple time in the same process/program, e.g a unit test fixture or framework. SDL_CreateWindow tend to randomly crash at times. I am not sure what cause the error, my guess is perhaps it might be related to the position independent code of the libraries when compiled.

Here is the gdb backtrace of it:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000050
0x00000001006afd8d in Cocoa_SetWindowGammaRamp (_this=0x10104e580, window=0x101033460, ramp=0x248) at SDL_cocoawindow.m:900
900	    CGDirectDisplayID display_id = ((SDL_DisplayData *)display->driverdata)->display;

(gdb) bt
#0  0x00000001006afd8d in Cocoa_SetWindowGammaRamp (_this=0x10104e580, window=0x101033460, ramp=0x248) at SDL_cocoawindow.m:900
#1  0x00000001006a0587 in SDL_OnWindowFocusLost (window=0x101033460) at SDL_video.c:1894
#2  0x00000001006064aa in SDL_SendWindowEvent (window=0x101033460, windowevent=13 '\r', data1=0, data2=0) at SDL_windowevents.c:157
#3  0x0000000100602af9 in SDL_SetKeyboardFocus (window=0x10104e8a0) at SDL_keyboard.c:612
#4  0x00000001006ad0f8 in -[Cocoa_WindowListener windowDidBecomeKey:] (self=0x10103caf0, _cmd=0x7fff83fcaadb, aNotification=0x100456b20) at SDL_cocoawindow.m:185
#5  0x00007fff8c603de2 in __-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_1 ()
#6  0x00007fff8c9f6e0a in _CFXNotificationPost ()
#7  0x00007fff8c5f0097 in -[NSNotificationCenter postNotificationName:object:userInfo:] ()
#8  0x00007fff8384b6d2 in -[NSWindow becomeKeyWindow] ()
#9  0x00007fff8384655b in -[NSWindow _changeKeyAndMainLimitedOK:] ()
#10 0x00007fff8384611c in -[NSWindow _makeKeyRegardlessOfVisibility] ()
#11 0x00007fff8384608d in -[NSWindow makeKeyAndOrderFront:] ()
#12 0x00000001006af063 in Cocoa_ShowWindow (_this=0x10104e580, window=0x10104e8a0) at SDL_cocoawindow.m:734
#13 0x000000010069ee90 in SDL_ShowWindow (window=0x10104e8a0) at SDL_video.c:1538
#14 0x000000010069dacb in SDL_FinishWindowCreation (window=0x10104e8a0, flags=6) at SDL_video.c:1123
#15 0x000000010069ddf6 in SDL_CreateWindow (title=0x1006e3d0f "Graphics Dummy Window", x=0, y=0, w=1, h=1, flags=6) at SDL_video.c:1188
Die: DW_TAG_unspecified_type (abbrev = 35, offset = 4199)
	has children: FALSE
	attributes:
		DW_AT_name (DW_FORM_string) string: "decltype(nullptr)"
Die: DW_TAG_unspecified_type (abbrev = 35, offset = 4199)
	has children: FALSE
	attributes:
		DW_AT_name (DW_FORM_string) string: "decltype(nullptr)"
Dwarf Error: Cannot find type of die....
Comment 1 Sam Lantinga 2012-01-08 10:59:06 UTC
Can you attach a simple crashing program?

Thanks!
Comment 2 jianann87 2012-01-13 06:56:30 UTC
Created attachment 766 [details]
simple app that can reproduce the crash

i think maybe the crash may be related to position independent code.
Comment 3 Sam Lantinga 2012-01-13 22:39:08 UTC
Fixed, thanks!
http://hg.libsdl.org/SDL/rev/b1a71f8189a6