I'm suddenly getting weird Malloc errors in my code such as:
malloc: *** error for object 0x7fbdc8daa2f8: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
-> 0x112fa4760 <+0>: pushq %rbp
0x112fa4761 <+1>: movq %rsp, %rbp
0x112fa4764 <+4>: nop
0x112fa4765 <+5>: nopl (%rax)
0x112fa4769 <+9>: popq %rbp
0x112fa476a <+10>: retq
The most common cause of this error is threading violations. For example, if one thread performs the final release on an object and begins to deallocate it, and then another thread which has an
unowned (Swift) or
assign (ObjC) reference to the object modifies it, that will trigger this error. (It should not be possible to get this error if all references are
weak, since it shouldn't be possible for the object to be deallocated in the former case, and
weak references are thread-safe in the latter case.)
It's of course possible that this is exposing a bug in the latest SDK (and so you should open a radar), but it is more typical that it's a bug in your code that changes in timing have caused to manifest. As noted, you should set a symbolic breakpoint on
malloc_error_break to find out what object is in question.