NewRelic crash with infinite recursion - ios

iOS frequently crashes with infinite recursion with following stack:
#7801 0x01c96241 in _writeJSONValue ()
#7802 0x01c9a660 in ___writeJSONArray_block_invoke ()
#7803 0x04bbad86 in __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke ()
#7804 0x04bbac92 in -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] ()
#7805 0x04b37ca5 in -[NSArray enumerateObjectsUsingBlock:] ()
....
#7822 0x04bbac92 in -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] ()
#7823 0x04b37ca5 in -[NSArray enumerateObjectsUsingBlock:] ()
#7824 0x01c9a571 in _writeJSONArray ()
#7825 0x01c96241 in _writeJSONValue ()
#7826 0x01c95f9d in -[_NSJSONWriter dataWithRootObject:options:error:] ()
#7827 0x01c98b57 in +[NSJSONSerialization dataWithJSONObject:options:error:] ()
#7828 0x001a7ec8 in ptrIntPtrParamHandler at /Users/jenkins/workspace/iOS v3 Agent -
EDIT, please look to the screen NewRelic generates the error, not mine code

This looks like an old bug with the agent (pre-v3.252). An update to the latest version of New Relic should fix this.

Related

NSInvalidArgumentException: -[__NSCFNumber count]: unrecognized selector sent to instance 0x8000000000000000

I am receiving this error from a bug report and have no idea what has caused it.
Here is the complete error message:
Hardware Model: [object Object]
Process: SkippersLog
Identifier: de.sioned.skipperslog
Version: 1.2.1
OS Version: iOS 13.6.1
NSInvalidArgumentException: -[__NSCFNumber count]: unrecognized selector sent to instance 0x8000000000000000
0 CoreFoundation ___exceptionPreprocess
1 libobjc.A.dylib _objc_exception_throw
2 CoreFoundation -[NSObject(NSObject) doesNotRecognizeSelector:]
3 CoreFoundation ____forwarding___
4 CoreFoundation ___forwarding_prep_0___
5 SkippersLog generic specialization <__C.CKRecordID, __C.CKRecord> of Swift.Dictionary._Variant.updateValue(_: __owned B, forKey: A) -> B? (<compiler-generated>)
6 SkippersLog updateValue (<compiler-generated>)
7 SkippersLog closure #1 () -> () in SkippersLog.CloudKitFactory.transferAllTablesToCloud() -> () (CloudKitFactory.swift:203:18)
8 SkippersLog reabstraction thunk helper from #escaping #callee_guaranteed () -> () to #escaping #callee_unowned #convention(block) () -> () (<compiler-generated>)
9 libdispatch.dylib __dispatch_call_block_and_release
10 libdispatch.dylib __dispatch_client_callout
11 libdispatch.dylib __dispatch_root_queue_drain
12 libdispatch.dylib __dispatch_worker_thread2
13 libsystem_pthread.dylib __pthread_wqthread
14 libsystem_pthread.dylib _start_wqthread
The only cause can be the updateRecords.updateValue(ckrecord, forKey: ckrecord.recordID) call in the following function:
func gatherCachedRecords()
{
var ckcaches : [CKCache] = []
*** filling ckcaches from database her ***
updateRecords.removeAll()
for ckcache in ckcaches
{
if let dbrecord = DBRecord.findDBRecord (recid:ckcache.recid)
{
let ckrecord = dbrecord.createCKRecord()
updateRecords.updateValue(ckrecord, forKey: ckrecord.recordID)
}
}
}
updateRecords is a property of the class defined as:
private var updateRecords : [CKRecord.ID: CKRecord] = [:]
gatherCachedRecords is called in global DispatchQueue:
func transferAllTablesToCloud()
{
CKManager.shared.activityIndicator(on: true)
DispatchQueue.global(qos: .utility).async
{
self.dispatchGroup = DispatchGroup()
self.gatherCachedRecords()
*** do some other stuff here ***
}
}
transferAllTablesToCloud is only called once during startup of the app. The only possible problem I could guess is, that updatedRecord is declared on class scope and not locally within the DispatchQueue block, but I have no idea why this could be a problem.
This should only cause trouble if transferAllTablesToCloud would be called more than once and at the same time running concurrently.
The class that hosts all this is a singleton.
I cannot reproduce this in my development environment.
Thanks in advance.

iOS Crash in UIViewController.presentViewController

I have an intermittent (rarely occurring) crash which, so far has only occurred in the wild with reports from AppStore. With the limited crash log, I have not been able to grok the issue.
I am trying to display an App Store Product page view.
Here is the code
The enclosing class includes the SKStoreProductViewControllerDelegate and
the delegate is set to self.
#objc func adTap(sender: UITapGestureRecognizer? = nil) -> Void {
if adAppID.isEmpty {return}
let paramDict = [SKStoreProductParameterITunesItemIdentifier: adAppID]
storeProductViewController.loadProduct(withParameters: paramDict, completionBlock: { (status: Bool, error: Error?) -> Void in
if status {
self.storeProductViewController.view.frame.origin.y = 0
let eventParams = ["AppID": self.adAppID]
self.present(self.storeProductViewController, animated: true, completion: nil)
}
else {
if let error = error {
print("Error: \(error.localizedDescription)")
}
}})
}
The error is triggered at the self.present:
#8 (null) in thunk for #escaping #callee_guaranteed (#unowned Bool, #guaranteed Error?) -> () ()
#7 0x100b68350 in closure #1 in ViewController.adTap(sender:)
#6 (null) in -[UIViewController presentViewController:animated:completion:] ()
#0 (null) in __exceptionPreprocess ()
Dumping the actual cashpoint file shows a SIGABRT:
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x1ad1db278 __exceptionPreprocess + 220 (NSException.m:199)
1 libobjc.A.dylib 0x1acf040a4 objc_exception_throw + 56 (objc-exception.mm:565)
2 UIKitCore 0x1b0bcbe0c -[UIViewController _presentViewController:withAnimationController:completion:] + 4880 (UIViewController.m:7185)
3 UIKitCore 0x1b0bce074 __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 104 (UIViewController.m:7671)
4 UIKitCore 0x1b0bce570 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 508 (UIViewController.m:7772)
5 UIKitCore 0x1b0bcdfc4 -[UIViewController _presentViewController:animated:completion:] + 196 (UIViewController.m:7678)
6 UIKitCore 0x1b0bce22c -[UIViewController presentViewController:animated:completion:] + 160 (UIViewController.m:7716)
7 MyAppName 0x100b68350 closure #1 in ViewController.adTap(sender:) + 1016 (ViewController.swift:991)
8 MyAppName 0x100b68580 thunk for #escaping #callee_guaranteed (#unowned Bool, #guaranteed Error?) -> () + 60 (<compiler-generated>:0)
9 StoreKit 0x1bba3c1e8 -[SKStoreProductViewController _loadDidFinishWithResult:error:] + 48 (SKStoreProductViewController.m:425)
10 StoreKit 0x1bba3e624 -[SKRemoteProductViewController loadDidFinishWithResult:error:] + 128 (SKRemoteProductViewController.m:61)
///////
I understand that the completion block is an implicitly escaping block, but I do not see how it does not fulfill the block spec (arguments, if indeed that is the issue). Again, this is an intermittent event. Never seen it on a device tethered to Xcode or on one of our untethered devices. Recently it has occurred in the field, once on a iPhone 7 running iOS 13, and once on a X running 12.3.1
/////
Any thoughts would be appreciated
Let me write this as answer, as I see now that my comment may be unclear. The block
if status {
self.storeProductViewController.view.frame.origin.y = 0
let eventParams = ["AppID": self.adAppID]
self.present(self.storeProductViewController, animated: true, completion: nil)
}
accesses some UI elements, yet it may not be running on main thread (since it's inside callback). So first thing I would suspect is that it's crashing if it happens to be called outside of main thread. Hence I would try this:
if status {
DispatchQueue.main.async {
self.storeProductViewController.view.frame.origin.y = 0
let eventParams = ["AppID": self.adAppID]
self.present(self.storeProductViewController, animated: true, completion: nil)
}
}
If it helps, maybe think of better MVC separation...

[CFString release]: message sent to deallocated instance

I've been struggling with a strange problem for two days now. I went through every related question on SO but none solved the issue. I'm working on Xcode5. I'm using ARC and CoreData.
On iOS7 (simulator):
`[CFString release]: message sent to deallocated instance`
Thread 1, Queue : com.apple.main-thread
0 0x03c7d3ba in __kill ()
1 0x03c7c4b8 in kill$UNIX2003 ()
2 0x0347a921 in ___forwarding___ ()
3 0x0347a4ee in _CF_forwarding_prep_0 ()
4 0x02b7b002 in -[NSConcreteAttributedString dealloc] ()
5 0x02f66692 in objc_object::sidetable_release(bool) ()
6 0x02f65e81 in objc_release ()
7 0x02f66ce7 in (anonymous namespace)::AutoreleasePoolPage::pop(void*) ()
8 0x00739bc4 in CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) ()
9 0x0345253e in __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ ()
10 0x0345248f in __CFRunLoopDoObservers ()
11 0x034303b4 in __CFRunLoopRun ()
12 0x0342fb33 in CFRunLoopRunSpecific ()
13 0x0342f94b in CFRunLoopRunInMode ()
14 0x04bd19d7 in GSEventRunModal ()
15 0x04bd17fe in GSEventRun ()
16 0x0196794b in UIApplicationMain ()
17 0x0000262d in main
The Zombies Instruments point to the second line where I set the cell's text labels:
cell.txtLabel.text = _reservationModule.newReservationText;
cell.subtitleTxtLabel.text = _reservationModule.newReservationSubtitle;
_reservationModule is a Core Data entity featuring the string properties. It's defined in the view controller as #property (nonatomic, strong) ReservationModule *reservationModule;
The Zombie history:
Event Type ∆ RefCt RefCt Timestamp Responsible Library Responsible Caller
Malloc/Retain/Release (4) 01:01.114.922 CoreData _prepareResultsFromResultSet
0 Malloc +1 1 01:01.114.922 CoreData _prepareResultsFromResultSet
1 Retain +1 2 01:01.116.184 CoreData -[_CDSnapshot mutableCopy]
2 Release -1 1 01:01.318.588 MyApp -[ReservationModuleChoice2ViewController configureSubtitleImageTableViewCell:atIndexPath:]
3 Release -1 0 01:05.004.359 CoreData -[_CDSnapshot dealloc]
4 Zombie -1 01:07.441.465 CoreData -[_CDSnapshot dealloc]
They've never occurred on Xcode 4.6.x though.
Any help is highly appreciated!
Thanks!
The answer is trivial and hasn't anything to do with retain counters...
I oversaw that it isn't allowed to name variables/properties starting with new with ARC enabled. This obviously resulted in an over release thus generating the error...
From Apple documentation: https://developer.apple.com/library/ios/releasenotes/objectivec/rn-transitioningtoarc/introduction/introduction.html
To allow interoperation with manual retain-release code, ARC imposes a
constraint on method naming:
You cannot give an accessor a name that begins with new. This in turn
means that you can’t, for example, declare a property whose name
begins with new unless you specify a different getter

UIScrollView crashes if setContentOffset is called with animation

My application creates instances of a custom subclass of UIView and adds those instances placed horizontally adjacent to each other. When a new instance of my UIView class is created, I can add it to the UIScrollView and reset the contentsize. I then call
[UIScrollView setContentOffset:(some point) animated:NO].
This works just fine.
The issue is when I call the above mentioned method with animation, i.e.
[UIScrollView setContentOffset:(some point) animated:YES]
, the application crashes.
The call stack looks like this:
> #0 0x3145b870 in ___forwarding___ ()
> #1 0x313b6650 in _CF_forwarding_prep_0 ()
> #2 0x317d84a2 in -[UIAnimator stopAnimation:] ()
> #3 0x317d84a2 in -[UIAnimator stopAnimation:] ()
> #4 0x317d7f0e in -[UIAnimator(Static) _advance:withTimestamp:] ()
> #5 0x317d7e00 in -[UIAnimator(Static) _LCDHeartbeatCallback:] ()
> #6 0x3531d86e in CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long) ()
> #7 0x3531d7c4 in CA::Display::IOMFBDisplayLink::callback(__IOMobileFramebuffer*,
> unsigned long long, unsigned long long, unsigned long long, void*) ()
> #8 0x33a56000 in IOMobileFramebufferVsyncNotifyFunc ()
> #9 0x36e3c60c in IODispatchCalloutFromCFMessage ()
> #10 0x31422f12 in __CFMachPortPerform ()
> #11 0x3142d522 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
> #12 0x3142d4c4 in __CFRunLoopDoSource1 ()
> #13 0x3142c312 in __CFRunLoopRun ()
> #14 0x313af4a4 in CFRunLoopRunSpecific ()
> #15 0x313af36c in CFRunLoopRunInMode ()
> #16 0x32888438 in GSEventRunModal ()
> #17 0x316b4cd4 in UIApplicationMain ()
When I enable Zombies, the application output produces:
*** -[__NSArrayM removeObject:]: message sent to deallocated instance 0x113dbb10
Additional Info: UIScrollView's delegate is never set. I am using ARC.
I found my issue.
I was calling the method that called setContentOffset from a background thread.
BackgroundThread --> My random processing method --> Setup new UIView and add it to UIScrollView --> Call setContentOffset with animations
The above flow causes the crash. When I called the same processing method from the main thread, it worked just fine.
Apparently iOS does not like animations called from a background thread.
One of the views in the scrollView is getting released. Probably you "jump" over it when you turn animation off - when its on, the system tries to get a series of "snapshots" of the changes, and when it tries to access the one view boom down you go. So you can enable Zombies and find out exactly what type of object is getting the message, and in the debugger you can probably "po" that object.
Another way to do it would be to write our own test animation, move the contentOffset say 20 pixels at a time in a loop with no animation, and watch to see when it crashes (it surely will)!

Unable to reload TableView Data in iOS App

I find my self out of ideas trying to get this app to work. My app uses a split view to show to lists. the "Master" list should hold a list of the user's Facebook friends. Since the app does not force you to login, if you're not logged in yet it shows "You have no friends" in the list till you've logged in. My problem is that once I've loaded all the friends and call [self.tableView reloadData] my program crashes some in there, and despite my best attempts at debugging it I can't find it. The method is
- (void)request:(FBRequest *)request didLoad:(id)result
{
if ([result isKindOfClass:[NSArray class]] && ([result count] > 0)) {
result = [result objectAtIndex:0];
}
switch (((Facebook *)[Facebook shared]).currentCall) {
case graphUserFriends:
{
_friends = [NSMutableArray array];
NSArray *resultData = [result objectForKey:#"data"];
if ([resultData count] > 0)
{
for (NSUInteger i=0; i<[resultData count] && i < 25; i++)
{
NSDictionary *friendDictionary = [resultData objectAtIndex:i];
FbFriend * f = [[[FbFriend alloc] initWithName:[friendDictionary objectForKey:#"name"] Id:[friendDictionary objectForKey:#"id"]] autorelease];
[_friends addObject:f];
}
}
[self.tableView reloadData];
break;
}
default:
break;
}
}
The whole source code (and Xcode 4 project) can be downloaded from https://skydrive.live.com/redir.aspx?cid=04b38cdd7b38bb7f&resid=4B38CDD7B38BB7F!798&parid=4B38CDD7B38BB7F!470&authkey=!API4iVva95nZFL8
Console (At Crash):
GNU gdb 6.3.50-20050815 (Apple version gdb-1708) (Mon Aug 15 16:03:10 UTC 2011)
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "x86_64-apple-darwin".sharedlibrary apply-load-rules all
Attaching to process 48870.
Catchpoint 3 (throw)Pending breakpoint 1 - "objc_exception_throw" resolved
Current language: auto; currently objective-c
(gdb) bt
#0 0x0156ecf0 in objc_exception_throw ()
#1 0x013c9674 in -[__NSArrayI objectAtIndex:] ()
#2 0x00454805 in -[UITableViewDataSource tableView:heightForRowAtIndexPath:] ()
#3 0x0026427a in -[UITableViewController tableView:heightForRowAtIndexPath:] ()
#4 0x0020f548 in -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] ()
#5 0x00211722 in -[UITableViewRowData numberOfRows] ()
#6 0x000c17c7 in -[UITableView noteNumberOfRowsChanged] ()
#7 0x000c12c1 in -[UITableView reloadData] ()
#8 0x0000247e in -[MasterViewController request:didLoad:] (self=0x6a491e0, _cmd=0x12e65, request=0x681e930, result=0x6824250) at /Users/CheckM8/Documents/Xcode 4/Projects/iPeople4/iPeople4/MasterViewController.m:46
#9 0x00009d36 in -[FBRequest handleResponseData:] (self=0x681e930, _cmd=0x1397a, data=0x6a76c60) at /Users/CheckM8/Documents/Xcode 4/facebook-facebook-ios-sdk-74358cd/src/FBRequest.m:261
#10 0x0000a357 in -[FBRequest connectionDidFinishLoading:] (self=0x681e930, _cmd=0xade62e, connection=0x681ec40) at /Users/CheckM8/Documents/Xcode 4/facebook-facebook-ios-sdk-74358cd/src/FBRequest.m:346
#11 0x00a29a59 in ___NSURLConnectionDidFinishLoading_block_invoke_0 ()
#12 0x00a27e94 in __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 ()
#13 0x00a28eb7 in -[NSURLConnectionInternalConnection invokeForDelegate:] ()
#14 0x00a27e4f in -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] ()
#15 0x00a27fd5 in -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] ()
#16 0x0096cf6a in _NSURLConnectionDidFinishLoading ()
#17 0x0398fbbd in URLConnectionClient::_clientDidFinishLoading ()
#18 0x03a5c5ea in URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload ()
#19 0x03986298 in URLConnectionClient::processEvents ()
#20 0x03a5c16b in non-virtual thunk to URLConnectionInstanceData::multiplexerClientPerform() ()
#21 0x03986137 in MultiplexerSource::perform ()
#22 0x013b197f in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#23 0x01314b73 in __CFRunLoopDoSources0 ()
#24 0x01314454 in __CFRunLoopRun ()
#25 0x01313db4 in CFRunLoopRunSpecific ()
#26 0x01313ccb in CFRunLoopRunInMode ()
#27 0x012c6879 in GSEventRunModal ()
#28 0x012c693e in GSEventRun ()
#29 0x00034a9b in UIApplicationMain ()
#30 0x00001d82 in main (argc=1, argv=0xbfffed64) at /Users/CheckM8/Documents/Xcode 4/Projects/iPeople4/iPeople4/main.m:16
#31 0x00001cf5 in start ()
You've made the classic memory management mistake: You're directly accessing your ivars and it burned you.
_friends = [NSMutableArray array];
This is an under-retain (which will crash later), and also a possible leak if _friends had a prior value. You should always use accessors for your ivars except in dealloc and init:
self.friends = [NSMutableArray array];
...
[self.friends addObject:f];
EDIT: From your stacktrace, your bug is in your table view data source's tableView:heightForRowAtIndexPath:. It looks like you're reading off the end of your array.

Resources