adhoc different then device debug?

Member
Posts: 306
Joined: 2009.03
Post: #1
In my app I hit a bug where running on my phone in adhoc mode, i get a crash(illegal access during a memcopy that works fine normally) during startup as I am pre loading all my images. This doesn't happen on the device in debug mode. Its a 3gs and the crash happens right around 21 megs of application usage. That may be high normally but for a 3s? And why would it work on debug mode? Application works fine also if I just delay loading some of that.

Is there possibly a difference in cleanup speed where in adhoc mode, doing so much at once left some other memory occupied(eg temporary buffers used to copy images) where in debug it gets freed and available sooner?
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #2
During debugging, all allocated memory is zeroed, but that is not so when run without the debugger, which I presume is what you are hitting. In other words, you have some uninited variable or chunk of memory somewhere.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #3
What's even more frustrating is when you have a memory bug like that which only happens when the debugger is not attached. That has happened to me more than once.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #4
Thats interesting. However if not preloading some image at startup and doing it later gets me past the problem, that doesn't fit the problem you mentioned. But I will look more closely for something related to that.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #5
It certainly does fit the problem, as later in the session you'll be getting back different memory from malloc, and it might just so happen that due to the allocation pattern, you get memory which contains values that don't provoke a crash, most or all of the time. Or possibly, you write sensible values in the memory in the meantime, through some seemingly unrelated process.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #6
Well the other issue that you run into with debug vs optimized builds is that local variables might be optimized away and never exist on the stack. This is an issue if you accessed a variable before initializing it. In the debug case you are getting garbage from the last function that used the stack, and in the optimized case you are getting garbage from whatever function last used the register that the variable occupies. The other possibility is that because some variables got optimized away, you are now getting stack garbage from a different location.

I've had issues with that before where I forgot to initialize a floating point number to 0 when I declared it. As debug the stack garbage was consistently a very very small floating point number so I didn't notice. When optimized the variable was getting garbage from somewhere else, and would sometimes be a very large number. This made it impossible to figure out the error using the debugger. As a result I rarely ever declare a variable not without initializing it on the same line and I cringe every time I can't.

C can be a fun language no? Rasp

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Member
Posts: 440
Joined: 2002.09
Post: #7
Turning on the static analyzer will point out uninitialized variables and such. So be sure to try that!
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #8
This is great input guys. Thanks a lot.
Quote this message in a reply
Member
Posts: 306
Joined: 2009.03
Post: #9
I was just recalling a time when I hit an issue because I used malloc instead of calloc for an art asset and it had random junk. If all allocated memory is 0ed in debug mode, how would this have been an issue?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Changing Configuration from "Debug" to "Release" causes Graphics Bugs Bersaelor 6 3,927 Jun 28, 2010 06:30 AM
Last Post: Skorche
  app crashes in non-debug environment Gillissie 2 2,876 Dec 12, 2009 05:03 PM
Last Post: DoG
  Creating an adhoc build for a reviewer EndeavorBros 1 2,049 Nov 18, 2009 04:03 PM
Last Post: AnotherJake
  huge size difference in adhoc vs dist and lite vs full kendric 1 2,170 Aug 13, 2009 04:02 PM
Last Post: ThemsAllTook
  adhoc update kendric 2 2,122 Jul 15, 2009 08:17 AM
Last Post: kendric