Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to diagnose a KERN_PROTECTION_FAILURE

I am getting an interesting crash that I can never seem to replicate on the simulator:

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000008
Crashed Thread:  0

Thread 0 Crashed:
0   libobjc.A.dylib                 0x3212e86c 0x3212c000 + 10348
1   StockTwits                      0x00016b06 0x1000 + 88838
2   Foundation                      0x30718422 0x306db000 + 250914
3   Foundation                      0x307183a4 0x306db000 + 250788
4   CFNetwork                       0x30933e74 0x30923000 + 69236
5   CFNetwork                       0x30927b70 0x30923000 + 19312
6   CFNetwork                       0x30927e62 0x30923000 + 20066
7   CFNetwork                       0x30927a60 0x30923000 + 19040
8   CFNetwork                       0x30927a12 0x30923000 + 18962
9   CFNetwork                       0x30927990 0x30923000 + 18832
10  CFNetwork                       0x3092790e 0x30923000 + 18702
11  CoreFoundation                  0x30352a86 0x302e1000 + 465542
12  CoreFoundation                  0x30354768 0x302e1000 + 472936
13  CoreFoundation                  0x30355504 0x302e1000 + 476420
14  CoreFoundation                  0x302fe8e4 0x302e1000 + 121060
15  CoreFoundation                  0x302fe7ec 0x302e1000 + 120812
16  GraphicsServices                0x31a776e8 0x31a74000 + 14056
17  GraphicsServices                0x31a77794 0x31a74000 + 14228
18  UIKit                           0x323272a0 0x32321000 + 25248
19  UIKit                           0x32325e10 0x32321000 + 19984
20  StockTwits                      0x00002fd4 0x1000 + 8148
21  StockTwits                      0x00002fa4 0x1000 + 8100

I have NSZombies enabled as well as stack logging. Ran through the static analyzer to make sure all objects are retained and released properly, though I have a feeling it is still related to retain/releasing.

Thoughts?

like image 294
Sheehan Alam Avatar asked Aug 05 '10 02:08

Sheehan Alam


People also ask

What does Kern_invalid_address mean?

EXC_BAD_ACCESS (SIGSEGV) KERN_INVALID_ADDRESS means that the virtual address you're refererencing is not in the page tables or you don't have access. It's a virtual address that you're not allowed to access.

What is Exc_bad_access Sigsegv?

What does EXC_BAD_ACCESS mean? EXC_BAD_ACCESS is an exception raised as a result of accessing bad memory. We're constantly working with pointers to memory in Swift that link to a specific memory address. An application will crash whenever we try to access a pointer that is invalid or no longer exists.


1 Answers

You must be dereferencing a NULL pointer, other than this crash does not happen. The Static Analyzer is a nice tool for getting hints on things you're doing wrong. However, it not finding an error does not mean that your program is bug-free. Also turning on zombies does not always help. Sometimes it's just a simple little oversight.

The fact the simulator does not show this problem doesn't say too much. In the end it's a different machine with a different processor and a different architecture. There are occasions where false code runs well on one platform but crashes on the other.

You should re-symbolicate you stack trace and have a close look at that function it's crashing in. If you want more help it's probably best to post some of the code here.

One more hint: these issues are often spread over multiple methods. The analyzer only sees one method at a time. You should have a look at what happened to the objects in your crashing method BEFORE it was entered.

like image 188
Max Seelemann Avatar answered Sep 23 '22 02:09

Max Seelemann