Game Development Community

FIXED: GDB: Program received signal: "0" & Memory Leak (iTGB 1.2)

by Rob Stiles · in iTorque 2D · 08/25/2009 (6:24 pm) · 46 replies

Hi,

I have the beginnings of a very basic platform game here. I've not modified the engine at all, I'm not allocating memory anywhere in script (other than local variables) and I'm execing my scripts all in one place in startGame() in game.cs, at the beginning of the game (not in a loop somewhere).

I'm using the regular iTGB build target, either in Release or Debug. If I run the game and leave it, it'll crash after about 4 minutes. The debugger just says "GDB: Program received signal: "0"".

If I open Organizer in Xcode and choose the Console tab I see this:

Tue Aug 25 21:52:15 unknown SpringBoard[23] <Warning>: Memory level is urgent (9%) and there are no background apps to ask to exit.
Tue Aug 25 21:53:18 unknown SpringBoard[23] <Warning>: Application 'MyGame' exited abnormally with signal 11: Segmentation fault
Tue Aug 25 21:53:19 unknown ReportCrash[4565] <Error>: Saved crashreport to /Library/Logs/CrashReporter/LowMemory-2009-08-25-215318.plist using uid: 0 gid: 0, synthetic_euid: 0 egid: 0

The crash report shows this:

Incident Identifier: 045BD190-D071-4AFE-B9A6-774503A8F8C3
CrashReporter Key: 5fd95a1e842ebce7c3a80c9d86ed697359c11367
OS Version: iPhone OS 3.0.1 (7A400)
Date: 2009-08-25 21:53:18 +0100

Free pages: 251
Wired pages: 8773
Purgeable pages: 0
Largest process: MyGame

Processes
Name UUID Count resident pages
securityd <8266b85008779d1e28f2509e51d303cf> 90
MyGame <73c36f64f5d4332638d08e312ea9aa84> 11744 (jettisoned) (active)
debugserver <b79865bab3ea06747ce03eaa9f7b7a8f> 109
DTMobileIS <a541ccb799a4e87cb10636268ab1b87b> 1238
notification_pro <09df4bf987a6baaa3e77192c4026bc5e> 61
syslog_relay <4adc9d69d534cb0be0649055b2188c4e> 62
notification_pro <09df4bf987a6baaa3e77192c4026bc5e> 62
notification_pro <09df4bf987a6baaa3e77192c4026bc5e> 62
afcd <08d114ca35c3e862bdb56df371c5d197> 64
ptpd <e1c6f82741b354c1086e373473131824> 172
MobilePhone <9517d3db1b487371c5a64e41bfd19eda> 589 (jettisoned)
debugserver <b79865bab3ea06747ce03eaa9f7b7a8f> 82
debugserver <b79865bab3ea06747ce03eaa9f7b7a8f> 82
mediaserverd <cc588f963f30bd34296bf8beeb803f8a> 435
SCHelper <fb330a127ccd71984188d2ce28d62716> 94
BTServer <3ae1c6fbcb29741b4a609b02f3c5a127> 178
iapd <3204da63503dec0812fa062678c61743> 246
notifyd <69e04d13344f1c006227422dbf18dde8> 108
CommCenter <e2b77989cdd88779b25322e1ef82b126> 419
SpringBoard <e0166bb2d42cbc489ace07849c959088> 2987 (active)
configd <2950435c092830011e402b4ac8ea86fe> 71
configd <2950435c092830011e402b4ac8ea86fe> 295
fairplayd <ec3c2c10efbb2e7a7b9d7130ecb1e2c6> 73
IQAgent <0c8ec49a509e684ffd4cae7729e2dcc9> 155
mDNSResponder <21273afce237d1ff8e79ab819a130e3c> 110
lockdownd <374e220ffb0f06ac0f7aa024a979e31f> 366
syslogd <4eae063fb35192e82cf5c47df1063443> 83
launchd <09ab79ab1b390e1fee1309f58948f17c> 105

**End**

It seems fairly obvious it's a memory leak but where from? I'm hoping other people here have had the same problem and fixed it - it must be a common thing since i'm using a virgin iTGB 1.2. I've only just bought it and I promise I've not changed any source code!
#21
09/17/2009 (1:09 am)
Phew! Okay! I think I got it! The trick was to make the preprocessor definitions match. So, instead of using the MACOSX definitions listed above, I made them:

__MACOSX__
TORQUE_PLAYER
TORQUE_RELEASE
TORQUE_DISABLE_MEMORY_MANAGER
PUAP_SCRIPT_CHANGE
PUAP_OPTIMIZE
USE_COMPONENTS

Then I did the usual game of compiling, cleaning, compiling again for iPhone... And after that - no EXC_BAD_ACCESS when the game started up!

So, I'm not sure if MACOSX should use the definitions originally listed above in this thread, since it caused a lot of problems still...
#22
09/17/2009 (7:52 am)
Hmm... yes the preprocessor definitions are definitely supposed to match. I read that somewhere else too. I thought they did but clearly I missed out TORQUE_RELEASE :) Thanks for that!

Edit: I've added TORQUE_RELEASE to the original post so that if anyone else tries it they don't have to go through these comments to figure out what was wrong.
#23
09/18/2009 (7:20 pm)
Hello,
I really can’t get this to work for me. Can anyone see what I’m doing wrong please?

I run the game in iTGB (using 1.3), play it a bit and then quit it so the scripts compile.
I then build the project (via iTGB) using the following settings:

OS 2.21 (also tried OS3.0)
Optimized Scripts
Device and Release settings
When trying to build using the __MACOSX__ stuff, I just get loads of errors.
Clicked on “Clean & Build”

Load up XCode.
Made sure that the OS and Device was correct in the drop down button.
Go into Edit Active Target “iTGB_Script_Optimize”

Set up the following:
Architectures:>
Base SDK = iPhone Device 2.2.1 (Also tried it set at OS 3.0)
----------------------------------------------
Code Signing:>
Code Signing Entitlements= dist.plist
Code Signing Identity = Set that up for my game.
----------------------------------------------
Compiler Version
C/C++ Compiler Version = GCC 4.0 (Also tried 4.2)
----------------------------------------------
Deployment
iPhone Os Deployment Target = OS 2.2.1 (Also tried OS 3.0)
----------------------------------------------
Linking
C++ Standard Library Type= Dynamic (Also tried Static)
----------------------------------------------
GCC 4.0 – Preprocessing:>
Preprocessor Macros:
__MACOSX__
TORQUE_DISABLE_MEMORY_MANAGER
TORQUE_PLAYER
TORQUE_RELEASE
PUAP_SCRIPT_CHANGE
PUAP_OPTIMIZE
USE_COMPONENTS
----------------------------------------------
Go into Build> Clear All Targets
Build> Build
This fails to build the project with 8359 errors and 5876 warnings!
I’ve tried again using various combinations of GCC and OS targets, but all fail to build. To be honest, I have no idea what this part of the process is for so I don’t even know what to expect to get from this.

I then went back into iTGB and run the game again and then rebuild the project in iTGB with the same settings as before.
OS 2.21 (also tried OS3.0)
Optimized Scripts
Device and Release settings
When trying to build using the __MACOSX__ stuff, I just get loads of errors.
Clicked on “Clean & Build”

In XCode, I go in to the Project and change the __MACOSX__ to __IPHONE__ (in the Preprocessor Macros bit)and run the project.
I’ve also added the Symbolic Link via the terminal which didn’t seem to make any difference.

It builds, but it either just sits on the iTGB splash screen (with iPhone task bar along the top) or with the new error message *Failed to open “Main.cs”*

I’m at a total loss with this and because I’ve upgraded to Snow Leopard and iTGB 1.3, I don’t know if this is part of the problem or it’s just the fact that I don’t know what the hell I’m doing and it’s late and I need to go to bed before I start to slap my computers around a bit ;)

If any one can point what ever it I’m doing wrong with this, I would be really grateful as I am getting really close to binning iTGB now (it’s really starting to feel like it’s more trouble then it’s worth now). Life is so much easier just been an artist ;)

Thanks in advance for any help any one can provide.

Cheers,
Mike.
#24
09/18/2009 (7:46 pm)
What messages are you seeing in GDB whenever it freezes on the iTGB splash screen? Does it say EXC_BAD_ACCESS?
#25
09/19/2009 (7:04 am)
Morning Dave,
No that's the strange thing, when it sits there on the splash screen, GDB just says RUNNING...
What is really, really strange is when I got up this morning, I just hit build and it worked on my iPod! Nothing was turned off or touched last night to change any configuration. I just left everything as is. So that's good, on the downside it still crashes after about 25 mins which looking through the crash log and console screen shows it as been a memory problem.
I'll look through the project settings again and see if I can see anything else I may of missed.
Thanks,
Mike.

#26
09/19/2009 (10:48 am)
Well I've been trying different build options again, but every time the game seems to crash due to memory errors after about 25 mins (which is 5 mins more then normal).
One of the (many) things I don't understand is what the __MACOSX__ process does? Every time I try that part, it just builds with 1000's of errors. And just to make sure that I'm doing it right,when building for the iPhone, I just change that section (Preprocessor Macros) from __MACOSX__ to __IPHONE__ and build again?

Well at least I've got it to build the game again and it runs for an extra 5 mins now =?
#27
09/21/2009 (7:00 pm)
@Mike: I've found that all of this only works if you are running GCC4.2 and building for iPhone 3.0. This will break 2.2.1 and lower compatibility, but Apple doesn't even support an OS earlier than 3.1, anyway.

So on the plus side, from what I can tell, is once you get this working, it addresses 99% of the problems. (I know it fixed almost all of mine).

On the negative side, you lose compatibility for any OS before 3.0 (but, again, I don't think that's a big deal. If a user is not using the most recent version of the iPhone / iPod Touch OS and they are having problems, than they should upgrade regardless).

I wonder if Michael Perry, or his successor, will let me roll some of these changes into the trunk. But again, with losing 2.2.1 and earlier compatibility, it might not be good. But then again... should we even care if we lose that?
#28
09/21/2009 (7:06 pm)
I haven't, and I'm use a ton of people haven't paid the $10 fee to upgrade from OS 2.2 to OS 3.0. There really isn't that compelling of a reason for the ipod touch.
#29
09/21/2009 (7:08 pm)
@Bret: I've heard there is quite a lot of software that will not run however without 3.0 on the iPod Touch. I haven't looked into that too much myself as I mostly use an iPhone upgraded to 3.0... have you heard much about the software incompatibilities?
#30
09/21/2009 (7:09 pm)
Is this fix working on the new 1.3 beta?
Also, is the new beta only supports iPhone 3.0 or 3.1 ?
Personally I prefer to keep using 2.2.1 since I believe a lot of the gamers out there are using iPod and not iPhone, which means they have to pay for OS upgrade and a lot of them haven't upgraded yet. although it's only a matter of time.
#31
09/21/2009 (7:14 pm)
I've never heard of any software not running on OS 2.2 on ipod touch. The only things you don't get are the new OS 3.0 features, which most applications conditionally support in order to work with 2.2 and OS 3.0.

The only reason I'd drop 2.2 support is if I had a really compelling reason to, like Bluetooth support and/or store front in app purchase.

I released my games first version with 2.2.1 support because I don't have networking nor in app purchase yet. As soon as I have support for those then I might be more likely to require 3.0.
#32
09/21/2009 (7:17 pm)
@Eyal: I've only done this fix on 1.2. Haven't worked with the 1.3 beta just yet.

So, from everyone who has done this fix, has anyone gotten the fixes listed in this thread to run on a 2.2.1 build of the iPod / iPhone OS, or does it only work on 3.0 like I am finding?
#33
09/22/2009 (12:11 am)
@Dave I don't believe this has anything to do with the OS version or the compiler version. I believe it's simply related to not having the exact same compile options for the version that compiles the DSO's and the version that runs on the iphone. I've personally never seen this problem, though I don't do a lot of script code so not real suprising, and I only use OS 2.2 for everything.

I've personally done a recursive diff on 1.2 -> 1.3 and there really isn't a lot of changes and none of them seem to be able to cause these problems your seeing.

Maybe try compiling with GCC 4.0 with SDK 3.1 targeting OS 2.2.1 and see if you see the problem? I personally recompile TGBGame for MAC and for iphone.
#34
09/24/2009 (2:11 am)
FYI you might want to check this out. According to this if you target OS 3.0+ only you are losing 49%+ of the market.
http://www.macrumors.com/iphone/2009/09/23/ad-request-metrics-reveal-iphone-os-3-1-adoption/

Of course that is only admob enabled applications but take it as you will.
#35
09/28/2009 (8:18 pm)
Currently the 2.x market is at best at 25%, shrinking.
The reduction of OS 3 to $5 for ipod owners (or $0 if you were smart enough to install 3.0 GM, as it upgrades to 3.1 for free) definitely made it less of a problem.

The largest hit for ipod owners was back with 1.1.x, where we payed $20 for the 1.1.4 update, whereas the update to 2.0 was already smaller and people not on 1.1.4+ didn't even have to pay the old upgrade fee ...
I think the upgrade to 4.0 will actually be 0 or near 0 (the reason its not 0 is not apple wanting cash but the deals with the phone providers as they pay for the support and updates)

Also, the fact that only 35% of the ipod touch users have upgraded yet isn't of that much importance. any device sold now is 3.0, that includes the itouch 2 and the itouch 3, so the market can only grow.
Any player will upgrade to 3.0 anyway, be it only for the bluetooth multiplayer as thats a strict 3.x only, as is ingame playlist usage for apps.
#36
09/28/2009 (11:17 pm)
Can you explain where you get the 25% number from and your 35% number from?

I agree it's shrinking but I do question where your percentages come from.
#37
10/03/2009 (4:18 pm)
So am I the only one that can't get this fix to work? I'm using iTGB 1.3 and targeting OS3.0 (on Snow Leopard)
I still don't understand why you try to build it with the __MACOSX__ first (which never works for me).
If I could get the apps to build without the memory leak, I would be a lot more confident about releasing more games using iTGB and it would stop a lot of bad reviews about my game crashing =(
Even if it means that I would lose the OS2.X market, it would be ok (not great, but I would live with it).

Thanks,
Mike.
#38
10/03/2009 (4:52 pm)
Mike,

You have to build the OSX Version first so you can compile your DSOs. The iPhone version does not compile DSOs, and requires them to already be compiled. So you first compile the OSX Version under the TGBGame project, making sure that your pre-processor definitions are IDENTICAL (minus the MACOSX flag) with the iTGB version. Run the game - make sure all your DSOs get compiled. Now compile your iTGB version, and see if it runs on the iPhone. If you get version conflicts, you will see this mentioned in GDB.
#39
10/04/2009 (4:11 pm)
Thanks for getting back Dave.
Right that makes sense, but unfortunately, that's what I've been doing, I think.
I’ve been through all the folders in the project and deleted all the DSO files so it builds new ones.
Run the game in iTGB and go through everything making sure that all the CS files are been run and converted into DSO files. I take it that there’s no hidden options in iTGB that I need to play around with for this?
Stop the game when happy and click on Build and select the options and let it run off to Xcode.
In Xcode. set up the project file as stated above and build and go.
This should then have the game up and loaded on your iPod / iPhone.
Only problem is that it dies after 20 mins =(

Thanks again for your help Dave.


#40
10/04/2009 (7:11 pm)
Which GCC compiler are you using? 4.0 or 4.2? I've only personally gotten this to work with 4.2 - 4.0 crashes frequently.