iOS: Crashes on resume from background

Hi all,

I have quite easily ported my little SDL2 game to iOS, but with the following problem: when I run my app, then press the iPhone home button to exit to “desktop”, and then return to my game right away, the game crashes at
SDL_render_gles2.c
in GLES2_RenderCopyEx function
in line rdata->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
with EXC_BAD_ACCESS.

This happens on iOS 6, on iPhone 4 and 4S. Sometimes, rarely, the game does not crash, but works with the status bar shown (the status bar is turned off initially), and the screen “shifted” down by the status bar.
On iOS 7 and iPhone 5S, the game never crashes, but the unwanted status bar always gets displayed. The status bar area is filled with the old screen content. Here is the screenshot of the game in this case:

[Image: http://s8.postimg.org/bl6ndaiu9/photo_1.jpg ] (http://postimg.org/image/bl6ndaiu9/)

Could someone please advice on how to resolve this situation?

Thank you,
Yevgeni.

Ok, I managed to fix the crash. The cause was I didn’t stop my game loop on SDL_APP_WILLENTERBACKGROUND / resume it on SDL_APP_WILLENTERFOREGROUND.

But the issue with the unwanted status bar appearing on resume is still there for iOS 6/7.

All right, fixed the issue with status bar gap at top also - thanks to the brilliant thread here (http://www.cocos2d-iphone.org/forums/topic/surface-size-480x300-because-of-statusbar-on-resume/), which pointed me to the right direction after struggling for the whole day.
I commented out [UIApplication sharedApplication].statusBarHidden = NO; line in UIKit_SetWindowFullscreen function in SDL_uikitwindow.m
I am not sure if this fix is suitable for merging into the repo, but I don’t see the point of showing the status bar if the app gets into background (when the fullscreen argument of UIKit_SetWindowFullscreen is false) - with all the problems following.

Anyway, I hope this will help someone (especially if the maintainers will manage to resolve this bug in the repo somehow).