user2776543
user2776543

Reputation:

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:

  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.

Upvotes: 55

Views: 107926

Answers (5)

Danian Oliveira
Danian Oliveira

Reputation: 31

I' am having the same issue.

I have a macOS 2015, big sur 11.7.

It all started when I updated my xcode. It seems that the last xcode version available for big sur has some bugs.

The fortran code that calls c++ and python plots was not running

I downgrade the xcode to 12.5, and the comand line tool for the this xcode version, but still have the same problem.

And it is intermitent. Some times code generate the error and sometimes not...

Upvotes: 0

MK Islam
MK Islam

Reputation: 1

If you have this problem. go to: product->scheme->diagnosis-> then enable mollic gaurd edge and zombie object then close then go product->stop then again product-build and run. best ofluck

Upvotes: 0

Ravi Raja Jangid
Ravi Raja Jangid

Reputation: 935

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.

Upvotes: 2

Pedro Soares
Pedro Soares

Reputation: 1195

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

Upvotes: 52

user1118321
user1118321

Reputation: 26395

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:

  1. you are freeing an object twice,

  2. you are freeing a pointer that was never allocated

  3. 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.

Upvotes: 30

Related Questions