21
GFF_MJ(3248,0x103f9ab80) malloc: Heap corruption detected, free list is damaged at 0x28298ffa0
*** Incorrect guard value: 0
GFF_MJ(3248,0x103f9ab80) malloc: *** set a breakpoint in malloc_error_break to debug

Error screenshot:

enter image description here

After running for a while, the app always crashes, but I won't get any information except the above tips. Now I don't know how to solve it, who can help me?

Thank you.

Arnab
  • 4,216
  • 2
  • 28
  • 50
GUOHUA
  • 213
  • 1
  • 2
  • 6
  • 1
    It always not easy to find problem. Try use code analyzer from Xcode, also turn on several diagnostics options: address sanitizer, undefined behaviour sanitizer, zombie objects, .etc. – Cy-4AH Sep 20 '18 at 08:30
  • I used code analyzer from Xcode,address sanitizer, undefined behaviour sanitizer and zombie objects to find problem. I have a lot of gains, thank you! @Kerberos – GUOHUA Sep 21 '18 at 10:19

3 Answers3

23

These bugs are no fun. Most likely, you have a buffer overflow somewhere or you are using a piece of memory after it has been freed and stomping on something else.

Since you can get it to crash in the debugger, that makes it much easier to track down.

Start by setting a breakpoint on malloc_error_break, as the error message instructs you to do. When you hit that breakpoint, that'll provide more of a clue, but still may be rather vague. However, you'll be able to post more clues and we can help you from there.

bbum
  • 162,346
  • 23
  • 271
  • 359
  • I tried a lot of methods, setting breakpoints and address analysis, zombie objects, and more. Eventually I generated the dSYM file for analysis to find and fix the problem (a timer did not terminate). thank you very much! – GUOHUA Jul 25 '19 at 02:18
  • 5
    Enabling `AddressSanitizer` honed in on the problem area straight away in my case. I was using deallocated memory - oops. –  Nov 05 '20 at 14:39
5

In my case, it was a problem with the simulator (with its memory).

Try to compile it in a real device after cleaning the build folder or close the simulator and run again.

akiliano
  • 51
  • 1
  • 2
5

I had this error on macOS. Cleaning build folder solved the issue.

Marek H
  • 5,173
  • 3
  • 31
  • 42