Lockup on application gaining focus

Hello,

I am the Mac OS X binary maintainer for BZFlag (http://bzflag.org). Our mac builds have used SDL 1.2 as the platform library for several years. I am having an issue with our mac builds which surfaced only recently. Although the application builds and runs successfully (I am using the official SDL 1.2.15 framework), the application locks up after it is hidden and then selected again using command-tab or the dock. The program outputs the following upon lockup:

Code:
sierra:bzflag-2.4.2 josh$ ./src/bzflag/bzflag
2012-10-07 14:39:02.387 bzflag[53511:903] *** Assertion failure in -[NSThemeFrame lockFocus], /SourceCache/AppKit/AppKit-1038.36/AppKit.subproj/NSView.m:5237
2012-10-07 14:39:02.397 bzflag[53511:903] HIToolbox: ignoring exception ‘-[NSThemeFrame(0x5242a0) lockFocus] failed with window=0x52a7d0, windowNumber=93, [self isHiddenOrHasHiddenAncestor]=0’ that raised inside Carbon event dispatch
(
0 CoreFoundation 0x974556ca __raiseError + 410
1 libobjc.A.dylib 0x90ea05a9 objc_exception_throw + 56
2 CoreFoundation 0x974553f8 +[NSException raise:format:arguments:] + 136
3 Foundation 0x9a4e96e7 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116
4 AppKit 0x93addc94 -[NSView lockFocus] + 280
5 AppKit 0x9405e5f5 -[NSWindow restoreCachedImage] + 214
6 SDL 0x00489c56 SDL_SoftStretch + 25617
7 Foundation 0x9a41fdb3 _nsnote_callback + 176
8 CoreFoundation 0x973dc763 __CFXNotificationPost + 947
9 CoreFoundation 0x973dc16a _CFXNotificationPostNotification + 186
10 Foundation 0x9a414c50 -[NSNotificationCenter postNotificationName:object:userInfo:] + 128
11 Foundation 0x9a42205d -[NSNotificationCenter postNotificationName:object:] + 56
12 AppKit 0x93a3e03d -[NSApplication _doUnhideWithoutActivation] + 1534
13 AppKit 0x93a3d9c3 _hideShowHandler + 121
14 HIToolbox 0x9704fc2f _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1567
15 HIToolbox 0x9704eef6 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 411
16 HIToolbox 0x970717f3 SendEventToEventTarget + 52
17 AppKit 0x93a0e9a3 _DPSNextEvent + 1885
18 AppKit 0x93a0ddd6 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 156
19 SDL 0x004857da SDL_SoftStretch + 8085
20 SDL 0x004665de SDL_PumpEvents + 44
21 SDL 0x00466616 SDL_PollEvent + 11
22 bzflag 0x001d0912 _ZNK10SDLDisplay14isEventPendingEv + 18
23 bzflag 0x00136870 _Z18processInputEventsf + 96
24 bzflag 0x0014bd33 _ZL11playingLoopv + 611
25 bzflag 0x0015001c _Z12startPlayingP10BzfDisplayR13SceneRenderer + 5916
26 bzflag 0x00115c8a SDL_main + 19706
27 bzflag 0x001c841c -[SDLMain applicationDidFinishLaunching:] + 76
28 Foundation 0x9a41fdb3 _nsnote_callback + 176
29 CoreFoundation 0x973dc763 __CFXNotificationPost + 947
30 CoreFoundation 0x973dc16a _CFXNotificationPostNotification + 186
31 Foundation 0x9a414c50 -[NSNotificationCenter postNotificationName:object:userInfo:] + 128
32 Foundation 0x9a42205d -[NSNotificationCenter postNotificationName:object:] + 56
33 AppKit 0x93a3e216 -[NSApplication _postDidFinishNotification] + 125
34 AppKit 0x93a3e126 -[NSApplication _sendFinishLaunchingNotification] + 74
35 AppKit 0x93b95339 -[NSApplication(NSAppleEventHandling) _handleAEOpen:] + 274
36 AppKit 0x93b94f59 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 101
37 Foundation 0x9a4551f8 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 511
38 Foundation 0x9a454fbc _NSAppleEventManagerGenericHandler + 228
39 AE 0x90f6df5c _Z20aeDispatchAppleEventPK6AEDescPS_mPh + 166
40 AE 0x90f6de5b ZL25dispatchEventAndSendReplyPK6AEDescPS + 43
41 AE 0x90f6dd65 aeProcessAppleEvent + 197
42 HIToolbox 0x97084197 AEProcessAppleEvent + 50
43 AppKit 0x93a0e7d2 _DPSNextEvent + 1420
44 AppKit 0x93a0ddd6 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 156
45 AppKit 0x939d01f3 -[NSApplication run] + 821
46 bzflag 0x001c8bc6 main + 1590
47 bzflag 0x0001c799 start + 53
)

The lockup does not occur when I change to another application and then back to BZFlag, only when I explicitly hide BZFlag and then change to it again. I have tried building with various versions of SDL down to 1.2.13, which all exhibit the issue (building with 1.2.12 does not exhibit the issue, although it is unstable in other ways, such as locking up upon keypresses intermittently). I build on Mac OS X 10.6.8, and have tried building against the Mac OS X 10.4u, 10.5, and 10.6 SDKs, and all builds exhibit the same issue (due to autotools usage, we are unable to move past 10.6 at this time). The resulting binaries do run on 10.7 and 10.8 but still exhibit the issue on those platforms.

As far as I could tell from the trace, the issue seems to have something to do with the way we interact with SDL, although I am confused because I use SDL in other projects which do not exhibit the issue. Is anyone able to offer some guidance about what might cause this, and whether or not this is actually an issue related to SDL?