14

My app runs perfect on simulator. But when I run it on device the app crash and display error :

"malloc: * error for object 0x17415d0c0: Invalid pointer dequeued from free list * set a breakpoint in malloc_error_break to debug";

I searched and set a breakpoint in malloc_error_break to debug, but still cannot find the problem. I tried to changed the scheme of project, enabled Zombie Object, but can not find the answer.

I also try to use instrument, but I am not good at it.

Nijat2018
  • 863
  • 2
  • 10
  • 26
  • Post the stacktrace at the time when the `malloc_error_break` fires. – trojanfoe Apr 30 '15 at 07:49
  • That's not a stacktrace. – trojanfoe Apr 30 '15 at 09:22
  • The lefthand side pane. Or you can type `bt` in the debugger (bottom pane). – trojanfoe Apr 30 '15 at 09:23
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/76621/discussion-between-uyghur-boy-and-trojanfoe). – Nijat2018 Apr 30 '15 at 09:27
  • Don't upload images. Include all code and errors as text. Images aren't searchable. – dandan78 May 04 '15 at 08:00
  • Sorry, after adding breakpoint on "malloc_error_break", I cannot find any stack trace. My app still crush with error "set a breakpoint in malloc_error_break to debug". Why I do not have any crash when I run this app on Simulator ? – Nijat2018 May 04 '15 at 10:02
  • I got this error on the function call removeFromSuperview() and I say that the view was not nil. Perhaps the superview was nil or the main image was already removed? – Sethmr Nov 16 '16 at 15:47

3 Answers3

13

I've fixed this error with Xcode 8 on iOS 8.3. I've just changed Deployment Target from 8.3 to 8.0. If the error appears now after migration to Xcode 8 and your device works under control iOS 8 it may be temporary decision.

UPD: Xcode 8.1 beta is fixed this error.

Andy Sander
  • 1,888
  • 1
  • 13
  • 16
2

Just fixed this same issue with Xcode 8. Preparing an iOS10 compatible build, updated to recommended Swift Migration 2.3, runs perfectly on iOS9 and iOS10 but crashes on iOS8.4. I reverted the changes in the code and the Main.storyboard and built the same content on the iOS8 with Xcode 7.3 fixed my issues.

Dani.Rangelov
  • 366
  • 2
  • 5
0

I met this strange error too, I google it and people said it is Swift's bug, hasn't been fixed. I debug line by line, find out the solution.

The reason this error appears

In EditRecordVC I have generic type function func update<RO>(operation: RO) where RO : RealmOperation, RO.R == EditRecordVC.R

In its subclass ConflictedRecordEditVC, I override the function, I input update, and Xcode helps me finishing the whole function override func update<RO>(record: Record?, operation: RO?) where RO : RealmOperation, RO.R == Record, compile well.

Run the code, after the overridden function is executed, this error will appear, the Xcode will stop at some random line, nobody can find out it is caused by this function.

I debug line by line, find out I have to change the generic type to override func update<RO>(operation: RO) where RO : RealmOperation, RO.R == Record, everything will work well again.

I forget when I added the ? by mistake and Xcode isn't angry.

So check you generic type function and make sure it is exactly same with super class

ygweric
  • 1,002
  • 1
  • 7
  • 22