Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ios Zombie detection

I'm having (in my opinion) a very difficult problem in my code. It crashes randomly at different places in the code. The project is a ARC project.

So my program crashes occaisonally with this messages:

malloc: *** error for object 0xd2dd8b0: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug

I already set a breakpoint for malloc_error_break but I don't get any information out of it. When the code crashes ,XCode shows me the place in the code where it happens. But as I already said the crashes are randomly and do not occur always. But it seems as if the crashes are concentrated at on particular line in the code.

Now, I wanted to debug it using the instruments that come with xcode. After a bit of googling i found the following stuff on stackoverflow: How do I set up NSZombieEnabled in Xcode 4? and Xcode malloc error.

So the first link describes how to start zombie detection out of xcode itself by clicking the run button in xcode and choose "Profile". The problem I have is, that I cannot find "Zombies" when choosing the template for the trace document in my version of xcode (4.2). But if I start Instruments outside xcode (e.g. from finder) I can choose zombies.

Okay, here is what I did:

1) Start Instruments from finder and choose Profile "Zombies".

2) Start iphone app from xcode in the iphone simulator (normal run (not profile or debug)).

3) In Instruments "Choose Target"->"Attach to process"->"iPhone Simulator (57529)".

4) Instruments begins to recod something (I cannot figure out what it does).

5) Start playing around with the app until it crashes.

Eventually the app crashes and here is a screenshot of instruments after crashing the app: enter image description here

My questions:

1) Is Zombies adequate for my problem or should I use another analyizes tool?

2) What tells me instruments in it's output after crashing?

like image 836
toom Avatar asked Mar 02 '12 12:03

toom


People also ask

What is Zombie in IOS?

Once an Objective-C or Swift object no longer has any strong references to it, the object is deallocated. Attempting to further send messages to the object as if it were still a valid object is a “use after free” issue, with the deallocated object still receiving messages called a zombie object.

How do I find zombie objects in Xcode?

Zombies are objects having retain count 0 still continuing to exist. To confirm it enable zombies in product -> Edit Schemes -> Diagnostics , enable the check mark for Zombie objects.

What is Exc_breakpoint?

EXC_BREAKPOINT (SIGTRAP) is a trace trap interrupted the process. It gives an attached debugger, if any, a chance to interrupt the process at a specific point in its execution.

What is NSZombie?

Ans : It's a memory debugging aid. Specifically, when you set NSZombieEnabled then whenever an object reaches retain count 0, rather than being deallocated it morphs itself into an NSZombie instance.


1 Answers

Judging by your description of the problem, your crash is caused by something besides accessing a zombie object. If your app accesses a deallocated (zombie) object, Instruments shows a message like the following when using the Zombies template:

enter image description here

like image 146
Swift Dev Journal Avatar answered Oct 04 '22 14:10

Swift Dev Journal