- (void)getFromWebwithCompletionBlock:(ResponseCallback)completionBlock
{
[/*
.... network call
*/
{
completionBlock();
}];
}
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000010
0 asd 0x1001dc2cc __69-[Engine getFromWebwithCompletionBlock:]_block_invoke (Engine.m:200)
1 asd 0x10010f4d8 -[NetworkCallService sendResponseForCall:] (NetworkCallService.m:422)
2 asd 0x10010f008 -[NetworkCallService respondSuccessWithData:responseData:] (NetworkCallService.m:396)
3 asd 0x10010e778 __43-[NetworkCallService connectWithRequest:]_block_invoke_2 (NetworkCallService.m:337)
4 libdispatch.dylib 0x193f39994 _dispatch_call_block_and_release + 24
5 libdispatch.dylib 0x193f39954 _dispatch_client_callout + 16
6 libdispatch.dylib 0x193f3e20c _dispatch_main_queue_callback_4CF + 1608
7 CoreFoundation 0x1820cb7f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
8 CoreFoundation 0x1820c98a0 __CFRunLoopRun + 1492
9 CoreFoundation 0x181ff52d4 CFRunLoopRunSpecific + 396
10 GraphicsServices 0x18b8136fc GSEventRunModal + 168
11 UIKit 0x186bbafac UIApplicationMain + 1488
12 Mobikwik 0x1000c8fcc main (main.m:16)
13 libdyld.dylib 0x193f66a08 start + 4
as far as i got from other stackoverflow posts my completionBlock is getting released before execution. My doubt here is if i am passing my completionBlock as an argument to the function, How can it be deallocated?
Isn’t my function’s class retaining the block? I am currently going to fix it by checking if completionBlock is nil, but i would like to know how can it ever be nil
Related
We are experiencing a weird issue on iOS16. There is no code change, it works fine on lower OS versions.
The stacktrace is:
The first case
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x00000000e5bde410
0
libobjc.A.dylib
objc_release_x21 + 16
1
CoreData
-[_PFManagedObjectReferenceQueue _processReferenceQueue:] + 1020
2
CoreData
-[NSManagedObjectContext _processRecentChanges:] + 112
3
CoreData
_performRunLoopAction + 412
4
CoreFoundation
__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
5
CoreFoundation
__CFRunLoopDoObservers + 532
6
CoreFoundation
__CFRunLoopRun + 1048
7
CoreFoundation
CFRunLoopRunSpecific + 612
8
GraphicsServices
GSEventRunModal + 164
9
UIKitCore
-[UIApplication _run] + 888
10
UIKitCore
UIApplicationMain + 340
The second case, I believe this stacktrace has the same root cause as the previous one (same trend, same UI page, only happens on iOS 16).
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0033003200390070
0
libobjc.A.dylib
objc_msgSend + 32
1
CoreFoundation
-[__NSArrayM dealloc] + 188
2
MyApplication
MyClass.m - Line 361
-[MyClass loadMessages:] + 361
3
MyApplication
MyClass.m - Line 125
__74-[MyClass requestRecentMessagesAndDiscardExistingMessagesCompletion:]_block_invoke + 125
4
libdispatch.dylib
_dispatch_call_block_and_release + 32
5
libdispatch.dylib
_dispatch_client_callout + 20
6
libdispatch.dylib
_dispatch_main_queue_drain + 928
7
libdispatch.dylib
_dispatch_main_queue_callback_4CF + 44
8
CoreFoundation
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
9
CoreFoundation
__CFRunLoopRun + 2036
10
CoreFoundation
CFRunLoopRunSpecific + 612
11
GraphicsServices
GSEventRunModal + 164
12
UIKitCore
-[UIApplication _run] + 888
13
UIKitCore
UIApplicationMain + 340
MyClass.m is an Objective-C class, it has a property:
#property (nonatomic, strong) NSArray<Message *> *messages; // Message is NSManagedObject
In the second stacktrace, frame -[OurClass loadMessages:] + 361, the messages array is deallocated:
self.messages = [[NSArray alloc] init...];
So my guess is, somehow the messages are over-released. If the messages are released in MyClass before, then the crash happens as the first stacktrace, otherwise it happens as the second stacktrace.
I've turned on -com.apple.CoreData.ConcurrencyDebug 1 to try to debug this, but no luck.
Any help would be much appreciated. Thanks in advance!
I got the logs from Firebase Crashlytics, my app is crashing but doesn't know where it is crashing. As crash logs are also not mentioning any specific line where the app is crashing. Please suggest if anybody else face such type of problem ever.
crash_info_entry_0
BUG IN CLIENT OF LIBDISPATCH: Over-resume of an object
crash_info_entry_1
CoreUI: deallocating _CUIInternalLinkRendition 44703 /System/Library/CoreServices/CoreGlyphs.bundle/Assets.car
Crashed: com.apple.main-thread
EXC_BREAKPOINT 0x00000001a64eba34
**Stack trace**
Crashed: com.apple.main-thread
0 libdispatch.dylib 0x1a64eba34 _dispatch_lane_resume + 700
1 libdispatch.dylib 0x1a64e5fd8 _dispatch_client_callout + 20
2 libdispatch.dylib 0x1a64e8758 _dispatch_continuation_pop + 408
3 libdispatch.dylib 0x1a64f8f18 _dispatch_source_invoke2 + 892
4 libdispatch.dylib 0x1a64f88c4 _dispatch_source_invoke + 428
5 libdispatch.dylib 0x1a64f1bb8 _dispatch_main_queue_callback_4CF + 696
6 CoreFoundation 0x1a67bbcc8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
7 CoreFoundation 0x1a67b6a24 __CFRunLoopRun + 1980
8 CoreFoundation 0x1a67b5f40 CFRunLoopRunSpecific + 480
9 GraphicsServices 0x1b0a46534 GSEventRunModal + 108
10 UIKitCore 0x1aa941580 UIApplicationMain + 1940
11 Big Idea Maths 0x1005ffa10 main + 14 (main.m:14)
12 libdyld.dylib 0x1a6634e18 start + 4
I am using HockeyApp for crash reporting and getting the following crash. I am unable to reproduce the crash. Can this be due to animating the scroll in the UICollectionView?
Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0x66dbc2408
Crashed Thread: 0
Application Specific Information:
Selector name found in current argument registers: indexAtPosition:
Thread 0 Crashed:
0 libobjc.A.dylib 0x0000000198e8c0b0 objc_retain + 16
1 UIKit 0x00000001898bade0 -[UICollectionViewData layoutAttributesForItemAtIndexPath:] + 248
2 UIKit 0x0000000189acb1dc -[UICollectionView scrollToItemAtIndexPath:atScrollPosition:animated:] + 256
3 MyApp 0x000000010016c33c -[CalendarView scrollToDate:animated:] (CalendarView.m:183)
4 MyApp 0x00000001001607cc __56-[CalendarViewController _updateHighlightedDateRange]_block_invoke (CalendarViewController.m:577)
5 libdispatch.dylib 0x00000001996916e8 _dispatch_call_block_and_release + 20
6 libdispatch.dylib 0x00000001996916a8 _dispatch_client_callout + 12
7 libdispatch.dylib 0x0000000199696db0 _dispatch_main_queue_callback_4CF + 1840
8 CoreFoundation 0x00000001842781f8 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
9 CoreFoundation 0x0000000184276060 __CFRunLoopRun + 1624
10 CoreFoundation 0x00000001841a4ca0 CFRunLoopRunSpecific + 380
11 GraphicsServices 0x000000018f3e0088 GSEventRunModal + 176
12 UIKit 0x00000001898bcffc UIApplicationMain + 200
13 MyApp 0x000000010015c2a4 main (main.m:12)
14 libdyld.dylib 0x00000001996c28b8 start + 0
I use Crashlytics to track crashes and I am seeing some crashes with the stack trace below:
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0xf8560b1c
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x37a20b66 objc_msgSend + 5
1 CoreFoundation 0x2d5f8e8d CFRelease + 560
2 QuartzCore 0x2fad2965 CA::release_objects(X::List<void const*>*) + 16
3 QuartzCore 0x2fad7dcf -[CAAnimation dealloc] + 54
4 libobjc.A.dylib 0x37a30b0b objc_object::sidetable_release(bool) + 174
5 CoreFoundation 0x2d5f8e8d CFRelease + 560
6 QuartzCore 0x2fada419 CA::Layer::run_animation_callbacks(void*) + 240
7 libdispatch.dylib 0x37f0a0af _dispatch_client_callout + 22
8 libdispatch.dylib 0x37f0c9a9 _dispatch_main_queue_callback_4CF + 268
9 CoreFoundation 0x2d6935b1 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
10 CoreFoundation 0x2d691e7d __CFRunLoopRun + 1308
11 CoreFoundation 0x2d5fc471 CFRunLoopRunSpecific + 524
12 CoreFoundation 0x2d5fc253 CFRunLoopRunInMode + 106
13 GraphicsServices 0x323362eb GSEventRunModal + 138
14 UIKit 0x2feb1845 UIApplicationMain + 1136
It looks like CFRelease is being called on some object twice. The problem is I have no idea which animation is causing the crash. The logs aren't very helpful as the crash happens in different places. How do I go about debugging/reproducing this crash or at the very least logging something so that I know what object is being released twice.
This is a bit of a weird one.
In my code, I have this line:
NSMutableArray *unresolvedPlayers = [NSMutableArray arrayWithCapacity:3];
This seems like a perfectly valid line. I crashed on this line with this stack trace (I have replaced my app name with xxxxxxxxx):
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0xc158f710
Triggered by Thread: 7
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0:
0 libsystem_kernel.dylib 0x3870d648 syscall_thread_switch + 8
1 libsystem_platform.dylib 0x3879a79a _os_lock_handoff_lock_slow + 74
2 libsystem_malloc.dylib 0x38748ece szone_malloc_should_clear + 50
3 libsystem_malloc.dylib 0x3874c444 malloc_zone_calloc + 92
4 libsystem_malloc.dylib 0x3874c3d2 calloc + 46
5 libobjc.A.dylib 0x380c8414 class_createInstance + 36
6 CoreFoundation 0x2a5773d0 __CFAllocateObject2 + 8
7 CoreFoundation 0x2a48c86a +[__NSArrayM __new:::::] + 38
8 CoreFoundation 0x2a48fd7c -[__NSPlaceholderArray initWithCapacity:] + 100
9 CoreFoundation 0x2a497e88 +[NSMutableArray arrayWithCapacity:] + 36
10 xxxxxxxxxx 0x001730f4 -[HostManager setHost:timestamp:] (HostManager.m:703)
11 xxxxxxxxxx 0x0016ff10 -[HostManager initSessionFromInvitation:] (HostManager.m:46)
12 xxxxxxxxxx 0x000ea68e -[NetworkController updateWithMatch:] (NetworkController.m:894)
13 xxxxxxxxxx 0x000ea418 __72-[NetworkController invitePlayersToMatch:playerGroup:completionHandler:]_block_invoke544 (NetworkController.m:844)
14 GameCenterFoundation 0x31263936 __72-[GKMatchmaker invitePlayersWithRequest:serverHosted:completionHandler:]_block_invoke601 + 42
15 libdispatch.dylib 0x38620420 _dispatch_call_block_and_release + 8
16 libdispatch.dylib 0x3862040c _dispatch_client_callout + 20
17 libdispatch.dylib 0x3862b1b0 _dispatch_main_queue_callback_4CF$VARIANT$mp + 708
18 CoreFoundation 0x2a53762c __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 4
19 CoreFoundation 0x2a535d4c __CFRunLoopRun + 1508
20 CoreFoundation 0x2a482b2c CFRunLoopRunSpecific + 472
21 CoreFoundation 0x2a48293e CFRunLoopRunInMode + 102
22 GraphicsServices 0x3183904c GSEventRunModal + 132
23 UIKit 0x2da786ec UIApplicationMain + 1436
24 xxxxxxxxxx 0x000503b2 main (main.m:16)
25 libdyld.dylib 0x3865baac start + 0
How is it possible that my memory has gotten corrupted up to this point that allocating a new NSMutableArray would cause this to happen? I'm not even sure where to start with debugging this one. I am not sure this is easily reproducible.
As a side note, it happened when inviting nearby players to a realtime GameCenter match.
EDIT: I just realized this is crashing on Thread 7. This is what Thread 7 looks like:
Thread 7 name: Dispatch queue: com.apple.root.default-qos
Thread 7 Crashed:
0 libobjc.A.dylib 0x380cbf66 objc_msgSend + 6
1 GameCenterFoundation 0x31285efc -[GKMatchmaker(Nearby) inviteAnyNearbyPlayersWithRequest:] + 960
2 GameCenterFoundation 0x312636a8 __72-[GKMatchmaker invitePlayersWithRequest:serverHosted:completionHandler:]_block_invoke + 256
3 GameCenterFoundation 0x3129ae92 __39-[GKDispatchGroup notifyOnQueue:block:]_block_invoke44 + 10
4 libdispatch.dylib 0x38620420 _dispatch_call_block_and_release + 8
5 libdispatch.dylib 0x3862c2d6 _dispatch_root_queue_drain + 846
6 libdispatch.dylib 0x3862d1f6 _dispatch_worker_thread3 + 102
7 libsystem_pthread.dylib 0x3879de22 _pthread_wqthread + 666
8 libsystem_pthread.dylib 0x3879db74 start_wqthread + 4
So, this is probably a bug with GameCenter.
Crash in objc_msgSend can indicate that message destination object is deallocated already. Try to enable zombie objects and keep your eyes on logs.