How to solve KERN_INVALID_ADDRESS on EXC_BAD_ACCESS (SIGSEGV)

Franck picture Franck · Oct 7, 2011 · Viewed 34.2k times · Source

On my mac OSX snow leopard and xcode 4.1 and the last SDK, My application crash on my phone but on my phone friend it don't crash.

I've got this error, I launch my application, wait RSS feed and after 2/3 seconds it crashed : Thank you for your help....

Date/Time:       2011-10-07 10:15:54.675 +0200
OS Version:      iPhone OS 4.3.3 (8J2)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x2040b743
Crashed Thread:  6

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib          0x332a5c00 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x332a5758 mach_msg + 44
2   CoreFoundation                  0x329382b8 __CFRunLoopServiceMachPort + 88
3   CoreFoundation                  0x3293a562 __CFRunLoopRun + 350
4   CoreFoundation                  0x328caebc CFRunLoopRunSpecific + 224
5   CoreFoundation                  0x328cadc4 CFRunLoopRunInMode + 52
6   GraphicsServices                0x33433418 GSEventRunModal + 108
7   GraphicsServices                0x334334c4 GSEventRun + 56
8   UIKit                           0x32417d62 -[UIApplication _run] + 398
9   UIKit                           0x32415800 UIApplicationMain + 664

Thread 1:
0   libsystem_kernel.dylib          0x332a83ec __workq_kernreturn + 8
1   libsystem_c.dylib               0x32c966d8 _pthread_wqthread + 592
2   libsystem_c.dylib               0x32c96bbc start_wqthread + 0

Thread 2 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 2:
0   libsystem_kernel.dylib          0x332a8fbc kevent + 24
1   libdispatch.dylib               0x30205032 _dispatch_mgr_invoke + 706
2   libdispatch.dylib               0x3020603a _dispatch_queue_invoke + 86
3   libdispatch.dylib               0x302055ea _dispatch_worker_thread2 + 186
4   libsystem_c.dylib               0x32c9658a _pthread_wqthread + 258
5   libsystem_c.dylib               0x32c96bbc start_wqthread + 0

Thread 3:
0   libsystem_kernel.dylib          0x332a7d18 __semwait_signal + 24
1   libsystem_c.dylib               0x32cbc860 _pthread_cond_wait + 756
2   libsystem_c.dylib               0x32c63eb2 pthread_cond_wait + 26
3   Foundation                      0x33846904 -[NSCondition wait] + 164
4   Cyntact.dylib                   0x0019cebe 0x19c000 + 3774
5   Foundation                      0x33839382 -[NSThread main] + 38
6   Foundation                      0x338ab5c6 __NSThread__main__ + 966
7   libsystem_c.dylib               0x32c9530a _pthread_start + 242
8   libsystem_c.dylib               0x32c96bb4 thread_start + 0

Thread 4 name:  WebThread
Thread 4:
0   libsystem_kernel.dylib          0x332a5c00 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x332a5758 mach_msg + 44
2   CoreFoundation                  0x329382b8 __CFRunLoopServiceMachPort + 88
3   CoreFoundation                  0x3293a562 __CFRunLoopRun + 350
4   CoreFoundation                  0x328caebc CFRunLoopRunSpecific + 224
5   CoreFoundation                  0x328cadc4 CFRunLoopRunInMode + 52
6   WebCore                         0x3114b27e RunWebThread(void*) + 382
7   libsystem_c.dylib               0x32c9530a _pthread_start + 242
8   libsystem_c.dylib               0x32c96bb4 thread_start + 0

Thread 5:
0   libsystem_kernel.dylib          0x332a5c00 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x332a5758 mach_msg + 44
2   CoreFoundation                  0x329382b8 __CFRunLoopServiceMachPort + 88
3   CoreFoundation                  0x3293a562 __CFRunLoopRun + 350
4   CoreFoundation                  0x328caebc CFRunLoopRunSpecific + 224
5   CoreFoundation                  0x3290d6d2 CFRunLoopRun + 42
6                               0x0003f96a 0x1000 + 256362
7   Foundation                      0x33839382 -[NSThread main] + 38
8   Foundation                      0x338ab5c6 __NSThread__main__ + 966
9   libsystem_c.dylib               0x32c9530a _pthread_start + 242
10  libsystem_c.dylib               0x32c96bb4 thread_start + 0

**Thread 6 Crashed:
0   libobjc.A.dylib                 0x32da1c98 objc_msgSend + 16
1   CoreFoundation                  0x328c519a CFRelease + 62
2   CFNetwork                       0x3563c378 HTTPMessage::~HTTPMessage() + 56
3   CFNetwork                       0x3563c336 HTTPMessage::~HTTPMessage() + 2
4   CFNetwork                       0x3563c262 CFClass::FinalizeObj(void const*) + 10
5   CoreFoundation                  0x328c5288 _CFRelease + 160
6   CoreFoundation                  0x328c51ae CFRelease + 82
7   CFNetwork                       0x3564ad52 HTTPReadFilter::~HTTPReadFilter() + 82
8   CFNetwork                       0x3564acf6 HTTPReadFilter::~HTTPReadFilter() + 2
9   CFNetwork                       0x3563c262 CFClass::FinalizeObj(void const*) + 10
10  CoreFoundation                  0x328c5288 _CFRelease + 160
11  CoreFoundation                  0x328c51ae CFRelease + 82
12  CFNetwork                       0x356ba7cc HTTPReadFilter::readStreamFinalize(__CFReadStream*) + 4
13  CFNetwork                       0x3564acea CFNetworkReadStream::httpStreamFinalize(__CFReadStream*, void*) + 10
14  CoreFoundation                  0x32940bd8 __CFStreamDeallocate + 120
15  CoreFoundation                  0x328c5288 _CFRelease + 160
16  CoreFoundation                  0x328c51ae CFRelease + 82
17  CFNetwork                       0x3564a7fc NetConnection::shutdownConnectionStreams() + 64
18  CFNetwork                       0x356b7b38 NetConnection::closeStreamsIfPossibleOrSignalThatThatNeedsToBeDonePrettyPlease() + 20
19  CFNetwork                       0x3568e018 NetConnection::doNotAllowMoreReqeusts() + 24
20  CFNetwork                       0x356c9324 UnauthConnectionArray::removeValueAtIndex(long) + 28
21  CFNetwork                       0x356c7ade HTTPConnectionCacheEntry::removeAllConnections() + 46
22  CFNetwork                       0x356c77ac HTTPConnectionCacheEntry::setHasBeenForgotten() + 20
23  CFNetwork                       0x356c78fc HTTPConnectionCacheDictionary::forgetCacheEntries() + 60
24  CFNetwork                       0x356c792c ConnectionCacheTLS::resetCacheForThisThread() + 12
25  CFNetwork                       0x35648aa0 ConnectionTimerTLS::_timerPurgeEntries(__CFRunLoopTimer*, void*) + 12
26  CoreFoundation                  0x32937a40 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
27  CoreFoundation                  0x32939ec4 __CFRunLoopDoTimer + 844
28  CoreFoundation                  0x3293a83e __CFRunLoopRun + 1082
29  CoreFoundation                  0x328caebc CFRunLoopRunSpecific + 224
30  CoreFoundation                  0x328cadc4 CFRunLoopRunInMode + 52
31  Foundation                      0x338467f6 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 206
32  Foundation                      0x33839382 -[NSThread main] + 38
33  Foundation                      0x338ab5c6 __NSThread__main__ + 966
34  libsystem_c.dylib               0x32c9530a _pthread_start + 242
35  libsystem_c.dylib               0x32c96bb4 thread_start + 0**

Thread 7 name:  com.apple.CFSocket.private
Thread 7:
0   libsystem_kernel.dylib          0x332a7c60 __select + 20
1   CoreFoundation                  0x3293d8f2 __CFSocketManager + 582
2   libsystem_c.dylib               0x32c9530a _pthread_start + 242
3   libsystem_c.dylib               0x32c96bb4 thread_start + 0

Answer

jbat100 picture jbat100 · Oct 7, 2011

EXC_BAD_ACCESS generally means that you are sending a obj c message to an invalid memory address. Usually this happens because an object that you are using has been deallocated, while you weren't expecting it to be (here, probably HTTPMessage).

**Thread 6 Crashed:
0   libobjc.A.dylib                 0x32da1c98 objc_msgSend + 16
1   CoreFoundation                  0x328c519a CFRelease + 62
2   CFNetwork                       0x3563c378 HTTPMessage::~HTTPMessage() + 56

The reason it works on another phone is probably just that autoreleased objects aren't being released at the same time. You should check your retain/release balances and can use NSZombieEnabled to get more information.