| Crash on SDL_SetVideoMode when called more than once (1.3) |
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
Sam Lantinga
|
I just tried this and it worked fine. Can you grab the latest snapshot (as of a couple of hours ago) and see if it still happens?
Thanks! On Fri, Feb 11, 2011 at 3:18 PM, josebagar wrote:
-- -Sam Lantinga, Founder and CEO, Galaxy Gameworks |
|||||||||||||
|
|
||||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
john skaller
Guest
|
On 12/02/2011, at 5:24 PM, Sam Lantinga wrote:
I had the same problem on OSX. It segfaults .. sometimes. I displays the right graphics .. sometimes. It never gets the textures right (but they work if you revert to the original size). -- john skaller _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
|
||||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
Kees Bakker
Guest
|
On 12 Feb, 2011, at 08:44 , john skaller wrote:
I recently switched to SDL 1.3 and I have this problem too. I'm working on TuxCap and I'm developing on MacOS. Lately I decided to try and port some TuxCap game to iOS, and that's why I switched to SDL 1.3 I've checked out the latest HG (as of three days ago). For some reason (which I have to solve some day) my program starts in windowed mode and then switches to full screen. And it crashes somewhere in SDL_SetVideoMode. I still don't have a good way to debug this because when SDL switches to full screen I can't debug anymore. I have to kill gdb remotely. With a small test program I can't get it to crash. So does anyone have some tips how to debug full screen SDL from a remote machine? BTW. I've used valgrind, and I have to repeat this once more. Perhaps that might give a hint. -- Kees _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
|
||||||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
john skaller
Guest
|
On 14/02/2011, at 2:10 AM, Kees Bakker wrote:
Are you static linking? I have both static and dynamic linking happening now, but the dynamic linking is screwing something up very badly. I do not believe this is SDL as such, It's probably something to do with Obj-C bindings to Cocoa or whatever Applish stuff is doing the window management. BTW: according to someone on StackOverflow the loss of textures when switching to full screen is a known bug: they have to be reloaded manually. It seems this doesn't work on a resize either. -- john skaller _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||
|
|
||||||||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
Kees Bakker
Guest
|
On 13 Feb, 2011, at 16:24 , john skaller wrote:
No, but I doubt that this would matter.
Hard to say. Here are some valgrind errors that analysing right now: Maybe I shouldn't be doing a SDL_FreeSurface myself. At least not for the one returned by SDL_SetVideoMode. ==6964== 1 errors in context 7 of 35: ==6964== Invalid free() / delete / delete[] ==6964== at 0x264BC8: free (vg_replace_malloc.c:366) ==6964== by 0x30D86E: SDL_FreeSurface (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/SDL.framework/Versions/1.3/SDL) ==6964== by 0x5375E2: Sexy::DDImage::~DDImage() (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x538217: Sexy::DDInterface::Cleanup() (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x5384CA: Sexy::DDInterface::Init(void*, bool) (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x3F1A11: Sexy::SexyAppBase::InitDDInterface() (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x3F28ED: Sexy::SexyAppBase::MakeWindow() (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x3F1C26: Sexy::SexyAppBase::SwitchScreenMode(bool, bool, bool) (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x3245C: GameApp::SwitchScreenMode(bool, bool, bool) (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x98DC0: WP_Options::switch_screen_mode() (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x9902A: WP_Options::set_user(std::string const&) (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x9BAA8: WP_Options::get_language() (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== Address 0x149f7e70 is 0 bytes inside a block of size 64 free'd ==6964== at 0x264BC8: free (vg_replace_malloc.c:366) ==6964== by 0x30D86E: SDL_FreeSurface (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/SDL.framework/Versions/1.3/SDL) ==6964== by 0x3F1DEB: Sexy::SexyAppBase::MakeWindow() (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x3F1C26: Sexy::SexyAppBase::SwitchScreenMode(bool, bool, bool) (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x3245C: GameApp::SwitchScreenMode(bool, bool, bool) (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x98DC0: WP_Options::switch_screen_mode() (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x9902A: WP_Options::set_user(std::string const&) (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x9BAA8: WP_Options::get_language() (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x32098: GameApp::Init() (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x6931: main (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== ==6964== 1 errors in context 8 of 35: ==6964== Invalid read of size 4 ==6964== at 0x30D843: SDL_FreeSurface (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/SDL.framework/Versions/1.3/SDL) ==6964== by 0x5375E2: Sexy::DDImage::~DDImage() (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x538217: Sexy::DDInterface::Cleanup() (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x5384CA: Sexy::DDInterface::Init(void*, bool) (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x3F1A11: Sexy::SexyAppBase::InitDDInterface() (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x3F28ED: Sexy::SexyAppBase::MakeWindow() (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x3F1C26: Sexy::SexyAppBase::SwitchScreenMode(bool, bool, bool) (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x3245C: GameApp::SwitchScreenMode(bool, bool, bool) (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x98DC0: WP_Options::switch_screen_mode() (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x9902A: WP_Options::set_user(std::string const&) (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x9BAA8: WP_Options::get_language() (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x32098: GameApp::Init() (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== Address 0x149f7e84 is 20 bytes inside a block of size 64 free'd ==6964== at 0x264BC8: free (vg_replace_malloc.c:366) ==6964== by 0x30D86E: SDL_FreeSurface (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/SDL.framework/Versions/1.3/SDL) ==6964== by 0x3F1DEB: Sexy::SexyAppBase::MakeWindow() (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x3F1C26: Sexy::SexyAppBase::SwitchScreenMode(bool, bool, bool) (in /Users/kees/src/lokokiboko/build-debug/src/LokoKiboko.app/Contents/Frameworks/tuxcap.framework/Versions/4.0/tuxcap) ==6964== by 0x3245C: GameApp::SwitchScreenMode(bool, bool, bool) (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x98DC0: WP_Options::switch_screen_mode() (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x9902A: WP_Options::set_user(std::string const&) (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x9BAA8: WP_Options::get_language() (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x32098: GameApp::Init() (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) ==6964== by 0x6931: main (in ./build-debug/src/LokoKiboko.app/Contents/MacOS/LokoKiboko) -- Kees _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||||||
|
|
||||||||||||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
Kees Bakker
Guest
|
On 13 Feb, 2011, at 17:29 , Kees Bakker wrote:
That's probably it. Here is a little test program to make it crash consistently. So we either have to make SDL_FreeSurface be aware of SDL_compat.c or we have to set some rules to not free the surface that you get from SDL_SetVideoMode. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
Kenneth Bull
Guest
|
On 13 February 2011 11:38, Kees Bakker wrote:
the display surface if I remember right... It wouldn't have worked with multiple display surfaces though. _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
|
||||||||||||||
|
josebagar
|
Has anybody tried the small sample code I posted?
[Edit] I mean that I'm assuming that it's a valida way of doing things, but maybe I'm just wrong. |
|||||||||||
|
|
||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
Kees Bakker
Guest
|
On 13 Feb, 2011, at 18:19 , josebagar wrote:
No, but Sam did, and he didn't see the crash. I can't say if your problem with SDL_SetVideoMode is the same as mine, but I just tried a workaround which seems to help: skip SDL_FreeSurface. If you look into video/SDL_surface.c then you'll notice that SDL_FreeSurface can delete a surface, but the code in SDL_compat.c never notices. If you do a new SDL_SetVideoMode then it will possibly free some surfaces that we're already freed. To repeat myself: We either have to make SDL_FreeSurface be aware of SDL_compat.c or we have to set some rules to not free the surface that you get from SDL_SetVideoMode. -- Kees |
|||||||||||||
|
|
||||||||||||||
|
josebagar
|
Ok, thanks for the info.
I'll try to switch the code that calls to SDL_SetVideoMode to SDL1.3 ASAP. Just in case it helps, I'm statically linking. If I can get some more detail, I'll let you know. Thanks for the info. |
|||||||||||
|
|
||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
john skaller
Guest
|
On 14/02/2011, at 3:29 AM, Kees Bakker wrote:
It might. It does for me. I have a function which outputs to a C++ ostringstream then grabs a string out of that, which is then part of an output to cout.. it works fine statically linked, it doesn't output when dynamically linked (but literal strings in the same output statement work). The same technology works fine in EVERY other dylib I generate there are 100 or so regression tests that all work fine, the SDL demos don't work properly but I've never seen a simple integer to string conversion function fail in dynamic linkage but work in static linkage .. but only when linking to SDL .. SDL may not be causing this problem directly, but its doing something nasty! It happens this is the only code I have with Objective-C component.
It's possible, since the surface is probably allocated by Objective-C, and there's some kind of NSFreePool thing you're supposed to use to release Obj-C heap values .. but this would have to be done right *inside* SDL. EVen statically linked, Obj-C itself tells me in one of the demos that there's no pool and it is going to leak the memory. So clearly the SDL bindings to the OSX windowing/graphics system aren't right yet. -- john skaller _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||||
|
|
||||||||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
Sam Lantinga
|
I'm making this change now, thanks!
On Sun, Feb 13, 2011 at 9:30 AM, Kees Bakker wrote:
-- -Sam Lantinga, Founder and CEO, Galaxy Gameworks |
|||||||||||||||
|
|
||||||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
Sam Lantinga
|
I fixed a leak in the mode change code recently, so if you're not using the latest SDL 1.3 snapshot you should upgrade.
You can also set a breakpoint in the function listed in the error message to catch the stack trace of where it's happening. If you do, can you please let me know where it is? Thanks! On Sun, Feb 13, 2011 at 10:27 AM, john skaller wrote:
-- -Sam Lantinga, Founder and CEO, Galaxy Gameworks |
|||||||||||||||||||
|
|
||||||||||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
john skaller
Guest
|
On 14/02/2011, at 5:30 AM, Sam Lantinga wrote:
I am using mercurial for the bleeding edge now. Static linkage on my demo # 3 is now working with resize, and also full screen. [this is a Felix recode of one of the NeHe demos, with nice coloured rotating cube and pyramid] Output looks like this: ~/felix> demos/sdl/sdl-1.01.03-0 98 frames in 5.001 seconds = 19.5961 FPS 23 frames in 5.001 seconds = 4.59908 FPS Resize w=784, h=608 Set video mode Resized now 73 frames in 5.03 seconds = 14.5129 FPS Resize w=934, h=772 Set video mode Resized now 75 frames in 5.015 seconds = 14.9551 FPS 99 frames in 5.002 seconds = 19.7921 FPS Resize w=1080, h=776 Set video mode Resized now Resize w=893, h=771 Set video mode Resized now 55 frames in 5.024 seconds = 10.9475 FPS 44 frames in 5.05 seconds = 8.71287 FPS 55 frames in 6.608 seconds = 8.32324 FPS Resize w=1280, h=800 Set video mode Resized now 71 frames in 5.031 seconds = 14.1125 FPS 87 frames in 5.027 seconds = 17.3065 FPS The same code running in a dylib (exactly the same C++ except for minor change to the call to the top level to use dlopen() instead of a static link) also now works but here's the output: frames in seconds = FPS frames in seconds = FPS frames in seconds = FPS frames in seconds = FPS frames in seconds = FPS Resize w=, h= Set video mode Resized now Resize w=, h= Set video mode Resized now frames in seconds = FPS frames in seconds = FPS Resize w=, h= Set video mode Resized now frames in seconds = FPS -- john skaller _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
|
||||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
john skaller
Guest
|
On 14/02/2011, at 6:14 AM, john skaller wrote:
Demo # 4 works, resizing happens BUT the textures are lost on resize. This is a rotating cube with NeHe written on it, using a texture. Same problem with dynamic linkage: textures lost, and in addition, frames in seconds = FPS frames in seconds = FPS numeric data lost (works with static linkage and the same routine works in 100 other dylibs). -- john skaller _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||||
|
|
||||||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
john skaller
Guest
|
On 14/02/2011, at 6:44 AM, john skaller wrote:
Well, demo #5 works and textures on this one are NOT lost on resize.. its the same rotating cube, as #4 but this time the rotation is controlled by the Keyboard. Interesting. Wonder why the textures aren't lost with this version.. -- john skaller _______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||
|
|
||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
Sam Lantinga
|
Okay, now trying to free the video surface won't do anything, as was the case in 1.2.
On Sun, Feb 13, 2011 at 10:28 AM, Sam Lantinga wrote:
-- -Sam Lantinga, Founder and CEO, Galaxy Gameworks |
|||||||||||||||||
|
|
||||||||||||||||||
|
josebagar
|
The code I posted now works great for me, without crashing and resizing the window just fine. Thanks a lot.
|
|||||||||||
|
|
||||||||||||
| Crash on SDL_SetVideoMode when called more than once (1.3) |
|
Sam Lantinga
|
Great, you're welcome! :)
On Sun, Feb 13, 2011 at 2:56 PM, josebagar wrote:
-- -Sam Lantinga, Founder and CEO, Galaxy Gameworks |
|||||||||||||
|
|
||||||||||||||

