30

I am trying to resolve a "message sent to deallocated instance " error in iOS.

user1274177
  • 311
  • 1
  • 4
  • 4

3 Answers3

43

See the LLDB-GDB command map (http://lldb.llvm.org/lldb-gdb.html) - you have to import a script, and the command is named malloc_info now. Obviously, malloc stack logging still needs to be turned on in the scheme options.

(lldb) script import lldb.macosx.heap
(lldb) malloc_info --stack-history 0x10010d680

Unfortunately, it doesn't show dealloc's - didn't GDBs malloc-history show that as well?

karstux
  • 1,482
  • 11
  • 8
  • when I looked at the linked page, it showed those commands as "available on Mac OS X only" – Walt Sellers Oct 09 '13 at 05:44
  • 5
    For me, the first line had to be 'command script import lldb.macosx.heap', otherwise the console would report 'error: 'malloc_info' is not a valid command.' (Mac OS) – Shaun Budhram Oct 31 '14 at 05:43
  • `(lldb) script import lldb.macosx.heap` *>>> "crashlog" and "save_crashlog" command installed, use the "--help" option for detailed help "malloc_info", "ptr_refs", "cstr_refs", "find_variable", and "objc_refs" commands have been installed, use the "--help" options on these commands for detailed help.* – Zeus May 20 '16 at 05:56
2

Use instruments, you'll get the exact line -

(In XCode) Run it through "Product" -> "Profile".

This will start Instruments, there you should choose "Zombies" and reproduce the bug event.

You'l get a pop-up once a zombie is called, press the chevron to see the exact line.

Problem is usually a bad __bridge (optional bridges __brige_retained / __bridge_transfer / __bridge)

Chintan Patel
  • 3,175
  • 3
  • 30
  • 36
Avishay Cohen
  • 2,418
  • 1
  • 22
  • 40
  • I'm not quite seeing the exact line. What might I be doing wrong? – lwdthe1 Jan 26 '17 at 03:51
  • @lwdthe1 You can see in Xcode output the deallocated Class that the message was sent to - it would give you a hint regarding the deallocated instance. – Avishay Cohen Jan 26 '17 at 11:06
0

You used to be able to use the malloc_history command-line tool from a shell and give it the process ID and address of interest. It appears this command is no longer installed by the latest Xcode's command line tools. :-(

Kevin Draz
  • 201
  • 2
  • 3