Henrybsbhp
Henrybsbhp

Reputation: 33

iOS 10 [CFString release]: message sent to deallocated instance

Recently, I've upgraded my iPhone to iOS 10. After I installed my app on the iPhone, I've found when I tap into a tableView in my app, it will definitely crash. I've made some breakpoint in the method cellForRowAtIndexPath and selected Zombie Objects in the Diagnostics sheet. But the message [CFString release]: message sent to deallocated instance 0x17063b960 always appeared in the Debug area. This issue only appear on the iOS 10 Beta, I'm not sure whether is iOS 10 Beta caused the issue. Does anyone met this issue like me? I'll be appreciated.

Updated:

When it return the cell, The crash will appear: Thread 1: EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0) and Thread 1: signal SIGKILL

Relevant code shown as blow:

UITableViewCell *cell;

HKLoadingModel * model = [self modelForTableView:tableView];
ShopServiceType type = model == self.carwashLoadingModel ? ShopServiceCarWash : ShopServiceCarwashWithHeart;
JTShop *shop = [model.datasource safetyObjectAtIndex:indexPath.section];
NSArray * serviceArray = [self filterShopServiceByType:type andArray:shop.shopServiceArray];
NSInteger serviceAmount = serviceArray.count;
NSInteger sectionAmount = 1 + serviceAmount + 1;

if(indexPath.row == 0)
{
    cell = [self tableView:tableView shopTitleCellAtIndexPath:indexPath];
}
else if (indexPath.row == sectionAmount - 1)
{
    cell = [self tableView:tableView shopNavigationCellAtIndexPath:indexPath];
}
else
{
    cell = [self tableView:tableView shopServiceCellAtIndexPath:indexPath andShopService:serviceArray];
}

return cell;

Upvotes: 2

Views: 1695

Answers (3)

sbhhbs
sbhhbs

Reputation: 625

We had the same crash and found the reason that lead to the crash. We used a 3rd party library called FoundationExtension, inside which overrided serval memeory management call in its NSObject category. We removed the library and it worked.

Upvotes: 1

ReDetection
ReDetection

Reputation: 3186

Try to use Instruments tool to track where you're passing a message to deallocated instance. Apple has good guide for that:

  1. Launch Instruments.
  2. In the profiling template selection dialog that appears, click Zombies.
  3. Choose your device and app from the target device and process lists.
  4. Click Choose to create a trace document.
  5. Click the Record button in the toolbar (or press Command-R) to begin recording.
  6. Use your app normally.
  7. If a call is made to a deallocated object, a flag is inserted in the timeline pane and a Zombie Messaged dialog appears, indicating that a message was sent to a deallocated object at a specific memory address.
  8. If you close the Zombie Messaged dialog, you can reopen it by clicking the flag.
  9. Click the focus arrow next to the zombie’s memory address to display the memory history of the zombie object in the detail pane, along with corresponding reference counts and method calls.
  10. Select the Zombie event (or any other event you want to investigate) in the detail pane.
  11. Press Command-3 to display a stack trace for the selected event in the extended detail area of the inspector.
  12. Click the Collapse button in the extended detail area to hide system calls in the stack trace. This makes it easier to locate your app’s methods.
  13. Calls made by your app are colored black and preceded by a user code icon.
  14. Double-click a method in the stack trace to display its code in Instruments.
  15. Click the Xcode button at the top of the detail pane to open the code in Xcode for editing.

In my case, crash was caused by FoundationExtension pod version 0.59. Once I removed it, I had no crash anymore.

Upvotes: 3

Bhadresh Mulsaniya
Bhadresh Mulsaniya

Reputation: 2640

Make sure your property is of type Strong.

Upvotes: 0

Related Questions