Crash in SDL_VideoQuit() and/or SDL_VideoInit()

Hi!

I’m not really sure if the problem i am currently facing actually is a libSDL Problem. My setup:
My OS is Ubuntu 8.04, SDL 1.2.13. The code is in c#, compiled and executed by mono 1.9.1 with SdlDotNet, which uses Tao.SDL bindings to access SDL functions.

I am currently trying to add a “minimize-to-tray”-feature to my application. As the builtin SDL “IconifyWindow”-function doesn’t work for me (Gnome) and doesn’t seem to support “balloon tips”, I decided to use a very dirty approach. On catching the SDL “Quit” event, my application adds a .NET “NotifyIcon” which seems to work fine so far with Gnome. Now, to hide the window - as there is no hide function for main windows - I try to shut down the Video Subsystem of SDL.
Yesterday, when playing around and hacking at my code, this seemed to work fine and I went on to implement the “show again on icon-doubleclick” feature. My application crashed when trying to do so, SIGSEGV. This usually indicates a problem with one of the “native-code” libraries used, as c# code is “managed” and therefore shouldn’t segfault.

The “managed” stacktrace looks like this:
at (wrapper managed-to-native) Tao.Sdl.Sdl.__SDL_Init (int) <0x00004>
at (wrapper managed-to-native) Tao.Sdl.Sdl.__SDL_Init (int) <0xffffffff>
at Tao.Sdl.Sdl.SDL_Init (int) <0x00084>
at SdlDotNet.Graphics.Video.Initialize () <0x00018>
at [my call to Graphics.Video.Initialize() ] […]

Then there is a “native” stacktrace:
/usr/bin/mono [0x818548a]
/usr/bin/mono [0x80800a1]
[0xb7fc9440]
/usr/lib/libX11.so.6 [0xb6c9e61f]
/usr/lib/libX11.so.6(XrmQGetResource+0x3e) [0xb6cb412e]
/usr/lib/libX11.so.6(XStringToKeysym+0x157) [0xb6cabf27]
/usr/lib/libX11.so.6(_XimParseStringFile+0xedf) [0xb6cdccef]
/usr/lib/libX11.so.6(_XimLocalOpenIM+0x3ce) [0xb6cda6ee]
/usr/lib/libX11.so.6(_XimOpenIM+0x146) [0xb6cd8e96]
/usr/lib/libX11.so.6(XOpenIM+0x4a) [0xb6cbe10a]
/usr/lib/libSDL-1.2.so.0 [0xb6d99e63]
/usr/lib/libSDL-1.2.so.0 [0xb6da3be7]
/usr/lib/libSDL-1.2.so.0 [0xb6da4b35]
/usr/lib/libSDL-1.2.so.0(SDL_VideoInit+0x20e) [0xb6d8fcae]
/usr/lib/libSDL-1.2.so.0(SDL_InitSubSystem+0x131) [0xb6d643b1]
/usr/lib/libSDL-1.2.so.0(SDL_Init+0x27) [0xb6d643f7]
[it goes on, but becomes rather cryptic after this ]

I don’t know how to interpret that native stacktrace. It seems like a problem in libX11?

So I sent the compiled .exe-file to a windows user. I was surprised when he told me that everything worked as intended, no crashes on windows. Since the application will be mainly used by windows users, I decided to just make this a windows-only feature. So when I started putting this feature into the development branch in a cleaned-up form, I encountered a very similar crash now even when minimizing (that is - closing the video subsystem, aka hiding the window) to tray. This is the managed stacktrace:

at (wrapper managed-to-native) Tao.Sdl.Sdl.SDL_QuitSubSystem (int) <0x00004>
at (wrapper managed-to-native) Tao.Sdl.Sdl.SDL_QuitSubSystem (int) <0xffffffff>
at SdlDotNet.Core.Events.CloseVideo () <0x0001b>
at SdlDotNet.Graphics.Video.Close () <0x00007>
at [my call to Video.Close () ] […]

And the native stacktrace:
/usr/bin/mono [0x818548a]
/usr/bin/mono [0x80800a1]
[0xb7f47440]
/usr/lib/libX11.so.6 [0xb6bb061f]
/usr/lib/libX11.so.6(XrmDestroyDatabase+0x2f) [0xb6bc63bf]
/usr/lib/libX11.so.6(_XFreeDisplayStructure+0x3ef) [0xb6bb1f4f]
/usr/lib/libX11.so.6(XCloseDisplay+0xf6) [0xb6b9efc6]
/usr/lib/libSDL-1.2.so.0 [0xb6caa5ae]
/usr/lib/libSDL-1.2.so.0 [0xb6cb42d2]
/usr/lib/libSDL-1.2.so.0(SDL_VideoQuit+0x50) [0xb6ca0e50]
/usr/lib/libSDL-1.2.so.0(SDL_QuitSubSystem+0x65) [0xb6c761f5]
[0xb4af0621]
[…]

Again, this seems to point into libX11’s direction. I went over my code a dozen times and compared it to what I used yesterday (which was working fine for hiding/closing), but couldn’t find any actually important changes. However, the development branch has some additional features now which my test-environment yesterday didn’t. They’re not related to initializing/quitting SDL, though. I haven’t had the chance to let this new - cleaned up - code be tested on windows yet.

I already checked SdlDotNet code which is somewhat buggy: Because of a logical error, the “SdlDotNet.Graphics.Video.IsInitialized” always returns false (it’s the counterpart for SDL_WasInit). I couldn’t find a way for this to influence calls to .Initialize() or .Close(), these always call SDL_WasInit directly, so I suspect it has nothing to do with this crash.

Even though I’m not sure the actual problem is with libSDL itself, I’d be most happy if someone could maybe point me in the right direction to try and solve this bug on Linux. I’d like to be able to just hide and show the window while the application is running.

Florian from Germany (and please excuse that **** ad signature this freemailer adds to my mails)_____________________________________________________________________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
http://smartsurfer.web.de/?mc=100071&distributionid=000000000066

I can’t believe this webmailer just sent my text
without automatic line breaks. I guess I’ll have to setup some
RFC-Compliant mail application to make sure this
won’t happen again. Sorry for your inconvenience!

Greetings,
Florian____________________________________________________________________
Psssst! Schon vom neuen WEB.DE MultiMessenger geh?rt?
Der kann`s mit allen: http://www.produkte.web.de/messenger/?did=3123