xcode 4: apps performance is affected by odd crash (debugger useless) - iphone

I am writing a side scrolling game app and am nearing the finish but out of nowhere this crash started happening almost every time I run now. I am debugging on a 4th gen Ipod touch.
The graphics will begin to lag and then my player movement will glitch and my player velocity will get stuck at a random speed. I receive no memory warnings and the game keeps on being playable despite the player speed being stuck. It does not exit out of the app.
Using the debugger has got me nowhere because it doesn't register with the debugger as anything going wrong. I guess it doesn't throw an exception.
I began watching the Device logs as I run the app and the lag starts to begin as im getting errors and warnings in device logs about:
ReportCrash[456] <Notice>: Formulating crash report for process AdSheet[454]
Sep 23 18:49:33 com.apple.launchd[1] <Warning>: (UIKitApplication:com.apple.AdSheetPhone[0xb005]) Job appears to have crashed: Abort trap: 6
Sep 23 18:49:33 backboardd[26] <Warning>: Application 'UIKitApplication:com.apple.AdSheetPhone[0xb005]' exited abnormally with signal 6: Abort trap: 6
Sep 23 18:49:33 ReportCrash[456] <Error>: libMobileGestalt copySystemVersionDictionaryValue: Could not lookup ReleaseType from system version dictionary
Sep 23 18:49:33 ReportCrash[456] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/AdSheet_2013-09-23-184932_Carla-Passs-iPod.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0
In the crash report it says it is a SIGABRT type crash but again I can't trace it back to any source code because the debugger doesnt recognize anything wrong.. Also I have no warning in my source code.
Any help would be much appreciated. Also i have the crash report if anyone wants to look at that hideous document.

Related

malloc: Heap corruption detected, free list is damaged

My app is running fine till iOS 12. After updating my iOS version to iOS 13 beta, the app is crashing in random places and with the same error. Following is the Xcode console.
MyApp(618,0x10cebd800) malloc: Heap corruption detected, free list is damaged at 0x28ea33ff0
*** Incorrect guard value: 5276115984
MyApp(618,0x10cebd800) malloc: *** set a breakpoint in malloc_error_break to debug
Any lead to debug/solve this will be appreciated. Thanks in advance.
As you stated, your app crashes in random places, I would also add in random times, this might be a clear sign of a retain cycle (could be because you forgot to capture a weak self inside a closure) somewhere in your code that led the heap to get saturated. At this point the system will certainly decide to terminate you app process and free up memory for other tasks.
In order to see this more clearly, try to profile your app (launch it with Instruments) with the Leaks profiling template, play around with the app and try to reproduce the scenario that led to the crash until it gets stopped (terminated), at this point Instruments will provide you with more details.

iOS app being killed (jettisoned) by mediaserverd memory issue (leak?) while streaming video

We are seeing a strange crash in which it appears that iOS is jettisoning our app along with mediaserverd after receiving a level 2 memory warning. It occurs while streaming DRM content (including, but not limited to, PlayReady encrypted content) about 7-8 minutes into playback - even if we have restarted the device with no other applications running in the background. This does not happen consistently, however, and we can sometimes complete the same piece of content (an entire 2 hour movie) with numerous memory-heavy applications in the background without any issues.
We are seeing this on iPhone 3GS, 4, and 4S devices running iOS 5.1 and 5.1.1, though it appears to be most prominent on a 3GS. The app is be terminated with either "segmentation fault 11" or "signal 9". Segmentation fault 11 can refer to bad memory access or low memory and signal 9 refers to low memory termination.
We have used both the static analyzer and instruments to find and fix any leaks and nothing alarming shows up in the Leaks instrument.
When analyzing playback using the Memory Monitor instrument, we see a dramatic decrease in available physical memory when we begin streaming, which is to be expected to a certain extent. When the application/os is behaving normally, other applications are removed from the background when memory becomes too low, but occasionally the available physical memory will simply continue to drop until the OS kills our app. No crash logs are generated, although we occasionally receive Low Memory logs, like the one below:
Incident Identifier: 13839D5B-D280-40D8-8C67-6EE3D61394C3
CrashReporter Key: d3746ff556543d6a94e067d82c8fb379a285f543
Hardware Model: iPhone2,1
OS Version: iPhone OS 5.1.1 (9B206)
Kernel Version: Darwin Kernel Version 11.0.0: Sun Apr 8 21:50:49 PDT
2012; root:xnu-1878.11.10~1/RELEASE_ARM_S5L8920X
Date: 2012-06-28 14:09:56 -0400
Time since snapshot: 104 ms
Free pages: 712
Active pages: 1433
Inactive pages: 1012
Throttled pages: 49925
Purgeable pages: 0
Wired pages: 11870
Largest process: SpringBoard
Processes
Name UUID Count resident pages
launchd <5fec01c378a030a8bd23062689abb07f> 79
securekeyvaultd. <78f602d3604c3bf487a27a288dec3bbb> 156
MYAPP <285e46965a91381dad0661443c8be3eb> 4035 (jettisoned) (active)
MobilePhone <8f3f3e982d9235acbff1e33881b0eb13> 749 (jettisoned)
mediaserverd <f03b746f09293fd39a6079c135e7ed00> 3670 (jettisoned)
networkd <80ba40030462385085b5b7e47601d48d> 145
apsd <e7a29f2034083510b5439c0fb5de7ef1> 260
SpringBoard <c74dc89dec1c3392b3f7ac891869644a> 4615 (active)
notifyd <f6a9aa19d33c3962aad3a77571017958> 170
BTServer <31e82dfa7ccd364fb8fcc650f6194790> 259
CommCenterClassi <041d4491826e3c6b911943eddf6aaac9> 421
aggregated <a12fa71e6997362c83e0c23d8b4eb5b7> 329
configd <ee72b01d85c33a24b3548fa40fbe519c> 324
fairplayd.N88 <ecb9495b29543b35a1f2e6c2b432528c> 168
fseventsd <914b28fa8f8a362fabcc47294380c81c> 164
iapd <0a747292a113307abb17216274976be5> 284
imagent <9c3a4f75d1303349a53fc6555ea25cd7> 412
locationd <cf31b0cddd2d3791a2bfcd6033c99045> 493
mDNSResponder <86ccd4633a6c3c7caf44f51ce4aca96d> 182
mediaremoted <327f00bfc10b3820b4a74b9666b0c758> 208
lockdownd <b06de06b9f6939d3afc607b968841ab9> 315
powerd <133b7397f5603cf8bef209d4172d6c39> 143
syslogd <7153b590e0353520a19b74a14654eaaa> 90
wifid <3001cd0a61fe357d95f170247e5458f5> 285
UserEventAgent <dc32e6824fd33bf189b266102751314f> 322
launchd <5fec01c378a030a8bd23062689abb07f> 120
End
According to some older questions I've seen on here, it seems that mediaserverd used to have serious problems with memory leaks in previous versions of iOS.
Could this be related to the issue?
How can we prevent this from happening?
Any ideas, theories, feedback, or similar issues would be greatly appreciated!
This is just a blind guess, but aren't you using AVFoundation's AVPlayer?
I had an issue like this, it turned out I wasn't releasing AVPlayers correctly. So for every song I created a new AVPlayer, which is fine if you release the old, but I didn't.
I found it out by doing an allocation test in Instruments and saw AVPlayers remain living after they supposed to be released.

why is launchd killing my app, that only uses 2 MB in RAM?

I am developing an app on iPod touch, that uses the camera, displays a preview and takes pictures (all that through an AVCaptureSession).
What I don't understand is that my app sometimes gets killed by launchd after a memory warning...although it uses no more than 2 MB in RAM (see attached screenshot).
The console tells me
Aug 16 15:16:35 Wiggler[109] <Warning>: Received memory warning. Level=1
...
Aug 16 15:16:58 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:com.tMyCompany.Wiggler[0xd83d]) Exited: Killed: 9
On the other hand, I can successfully run other apps that use tons of RAM (more than 100 MB) without any crash nor memory warning.
What is wrong with my app ? What am I missing ? Is it a bug or a memory leak within the AVFoundation (the framwork that provides AVCaptureSessions) ? I can't see why my app is killed while it uses so little memory...
Thanks for your help.
You almost surely are using more memory that what Allocations is showing you.
From your snapshot, it seems to me that you are not using the VM Tracker tool. Select the "snapshot automatically" option of the VM Tracker and then check both the "dirty" and "resident" size.
This will give you a more "global" view of your app memory usage. It will not help you to fix your allocation problems, if any, anyway, but at least it could explain why the memory warnings get in.
For an excellent explanation of what "dirty" and "resident" memory is, look at this from S.O.
Try configuring your AVCaptureSession for smaller captures and see what effect that has on dirty memory use. The GC can't collect memory that is in use (as part of the capture or preview, etc.)

App crashes with "Watchdog has expired." message. No stack trace or crash dump

My app is crashing with the following message in the Xcode debugger:
Watchdog has expired. Remote device was disconnected? Debugging session terminated.
The Debugger has exited due to signal 15 (SIGTERM).The Debugger has exited due to signal 15 (SIGTERM).
The crash is quite severe and reboots the device most of the time. The debugger just exits and I get no crash log afterwards.
Is the "Watchdog has expired." message relevant at all? Or is this just an artifact of the debugger loosing touch with the app when it crashes?
If it is relevant, what does it mean?
"Watchdog has expired." could mean anything. The way the message is worded suggests that the "local" GDB (running on your Mac) GDB timed out waiting for data from the "remote" GDB (running on the phone). Alternatively, "Watchdog has expired" might be from the phone's console output shortly before it reboots.
What does it display if you disconnect the device while your app is running? What if you power it off? What if you issue a hard reset (Sleep+Home for 10 seconds)?
If it's causing the device to reboot, there's something seriously wrong happening. Your app shouldn't be able to take the phone down, but sometimes something slips through (IIRC, UIImagePickerController on some version of 2.x had a problem where either your app would get killed or the phone would reboot, depending on which kicked in first). "Large set of bitmaps" sounds like it might be causing CoreAnimation (or IOSurface or whatever) to run out of video memory.
I would hesitate to do drawing in a background thread unless you're very careful about thread-safety (to a first approximation, CoreAnimation is and UIKit isn't except a few functions that were made "thread-safe" in 4.0).

iPhone development- where can I get a list of all signals received by apps and what they mean

My app crashes at a particular point when testing on the phone. The console shows this message
Tue Jan 27 15:47:14 unknown SpringBoard[22] <Warning>: Application <SBApplication: 0x3f26180> com.myprof.test activate: deactivate: exited abnormally with signal 10: Bus error
Where can I find a list with the meanings of all these signals?
Thanks.
Edit:
Is there a way of knowing why the error occurs? according to the signal man page, signal 10 is Bus error (which is BTW, clear from the error) but what does it mean and how do I remove it?
Thanks again
The signal man page
A bus error means that you're trying to access memory that the CPU can't physically access. As opposed to a segmentation fault, which means you're accessing memory that doesn't belong to you. Either way, you probably have a stray pointer.
Try using the memory allocation debugger in XCode (Guard Malloc). It will only run in the simulator and slows things down a lot, but I find it very useful.