EXC_BAD_ACCESS crash

Hi, I have been seeing this since some time, haven't been able to replicate this, could somebody help me understand why it is crashing here at this point?

Please refer to the function implementation here:

Code Block
public func crystalAPIObjecta(_ crystalAPIObject: ZV2CrystalAPIObject?,
             didFetchDataWithResponseObject responseObject: ZCrystalAPIResponseObject?,
             isPolling: Bool) {
    guard let responseObject = responseObject else { return }
    self.isPolling = isPolling
    responseObject.blockerItems?.forEach{ _ in /* */ }
    self.crystalResponseObject = responseObject /* crashing here at this point */
  }




Pls refer to the stack trace below:

Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000b2b50c4a0

Code Block
Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x1af25dde0 objc_release + 16
1 ZO2Kit 0x1030d6ae4 specialized ZV2CrystalVM.crystalAPIObject(_:didFetchDataWithResponseObject:isPolling:) + 255 (ZV2CrystalVM.swift:255)
2 ZO2Kit 0x103118198 partial apply for closure #1 in ZV2CrystalAPIObject.didFetchObjects(_:for:withInitialParams:) + 83 (ZV2CrystalAPIObject.swift:83)
3 ZO2Kit 0x1034d5c48 thunk for @escaping @callee_guaranteed () -> () + 4362771528 (<compiler-generated>:4362771528)
4 libdispatch.dylib 0x19aaf5298 _dispatch_call_block_and_release + 24
5 libdispatch.dylib 0x19aaf6280 _dispatch_client_callout + 16
6 libdispatch.dylib 0x19aaa505c _dispatch_main_queue_callback_4CF$VARIANT$mp + 896
7 CoreFoundation 0x19ae3d5e0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
8 CoreFoundation 0x19ae37a88 __CFRunLoopRun + 2480
9 CoreFoundation 0x19ae36ba0 CFRunLoopRunSpecific + 572
10 GraphicsServices 0x1b1b9c598 GSEventRunModal + 160
11 UIKitCore 0x19d7282f4 -[UIApplication _run] + 1052
12 UIKitCore 0x19d72d874 UIApplicationMain + 164
13 Zomato 0x1001242b4 main + 15 (main.m:15)
14 libdyld.dylib 0x19ab15568 start + 4

At first glance, you have a thread issue.

Where are you calling crystalAPIObjecta ?
Maybe some handler should be declared @escaping, otherwise you call objects which have already disappeared.

More code would be necessary to confirm.


EXC_BAD_ACCESS crash
 
 
Q