malloc: *** error: incorrect checksum for freed object - object was probably modified after being freed
I have a big problem with my iOS App: it crashes sometimes without detailed debug error. The stack trace is empty. These are the only two lines in the stack trace:
- crash start in UIApplicationMain at "symbol stub for: -[_UIHostedTextServiceSession dismissTextServiceAnimated:]".
- and report "libsystem_c.dylib`malloc_error_break".
in com.apple.main-thread
.
The error on Xcode debugger (with connected device):
malloc: *** error for object 0x208a7614: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
I have set a breakpoint in malloc_error_break with libsystem_c.dylib without any feedback from debugger. I have no idea to solve this issue.
Solution 1:
To find the source of the problem, in Xcode go to Product > Scheme > Edit Scheme, and under Diagnostics tab enable all the Malloc settings and Guard Malloc.
With that, run your application again, and Xcode will stop at the line causing the problem.
Solution 2:
Since you're in the debugger, you should look at the memory location 0x208a7614
and see what's there. The data in memory may be helpful in figuring out what's going wrong.
What's happening is one of the following:
you are freeing an object twice,
you are freeing a pointer that was never allocated
you are writing through an invalid pointer which previously pointed to an object which was already freed
Since the stack trace is coming up empty, it might be useful to add some debugging log statements to your code at various places to see if you can narrow down where in the code the problem lies. Using the memory tools in Instruments might also help. You could try turning on NSZombies, but this looks like a C allocation problem and not an Objective-C one.
Also, is anything else written to the console before the crash? If so, it may point you to where the problem is coming from.
Solution 3:
hi guys i have found this solution if you are using nib or xib interface and you facing this problem when you want to push a viewcontroller object then some time this error will occur and your app will be crash (specially error in iPad) Here is the solution:
// Format like this
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:yourViewControllerObj];
[self.navigationController presentViewController:nav animated:true completion:nil];
Don't try to push in this condition.