8

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?

Sheehan Alam
  • 60,111
  • 124
  • 355
  • 556
  • 1
    Aren't you passing an int of value 8 (0x00000008) somewhere instead of a pointer? – mvds Aug 05 '10 at 02:34
  • Can you explain a little more? Interesting... – Sheehan Alam Aug 05 '10 at 02:35
  • 1
    See this question for more info: http://stackoverflow.com/questions/1282428/whats-the-difference-between-kern-invalid-address-and-kern-protection-failure – mvds Aug 05 '10 at 02:36

1 Answers1

3

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.

Dragonrage
  • 205
  • 6
  • 17
Max Seelemann
  • 9,344
  • 4
  • 34
  • 40
  • 1
    The easiest way is to not compile with optimizations at all. Make a Debug configuration build that contains debug symbols. For Symbolicating you might find the answer here: http://stackoverflow.com/questions/1460892/symbolicating-iphone-app-crash-reports – Max Seelemann Aug 07 '10 at 09:07
  • 3
    For future readers, dereferencing a NULL pointer is NOT the only reason this crash happens, as it is stated in Apple's document `The process attempted to access invalid memory, or it attempted to access memory in a manner not allowed by the memory's protection level (e.g, writing to read-only memory).` Also, [this post](http://stackoverflow.com/questions/23717889/exc-bad-access-kern-protection-failure) shows this exception type due to a stack overflow. – funct7 Jan 04 '17 at 09:07