malloc: *** error: incorrect checksum for freed object - object was probably modified after being freed

user2776543 picture user2776543 · Nov 7, 2013 · Viewed 88.6k times · Source

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:

  1. crash start in UIApplicationMain at "symbol stub for: -[_UIHostedTextServiceSession dismissTextServiceAnimated:]".
  2. 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.

Answer

Pedro Soares picture Pedro Soares · Mar 15, 2014

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.

Scheme definition