My Cocoa Objective-C app (in XCode) occasionally crashes in the part where it calls a 3rd party API. I believe that it's a memory leak or something. I attach the part where my program will, the 3rd party API and the crash log.
Please help to give me pointers on how I can solve this. Thanks a lot!
My code:
.
.
.
uint8_t InfoProg[4];//10
uint8_t nInfoProg = 4;//10
uint8_t ret;
NSString *result;
NSLog(@"***Calling GetConnectedProgramers***");
ret = GetConnectedProgrammers(InfoProg, nInfoProg); // The part where it crashes sometimes
.
.
.
3rd party API function:
/**
GET INFO ON CONNECTED USB PROGRAMMERS
reports back the number of connected USB programmer devices on the host
@param InfoProg
points to the memory that will be filled with the info on the connected
USB programmers;
it is the responsibility of the application to allocate this memory
and to size it sufficiently. This should be an buffer with at least 8 bytes.
InfoProg[x] = 0; no USB programmer allocated to that number
InfoProg[x] = 1; USB programmer allocated to that number = USB programmer available
@param nInfoProg
is the number of requested data structures
@return
is the number of programmers connected
*/
uint8_t GetConnectedProgrammers (uint8_t *InfoProg, uint8_t nInfoProg);
Crash Report:
Process: FCT_MACOS [575]
Path: /Virgo_FG2_EVT/FCT_MACOS3p55c.app/Contents/MacOS/FCT_MACOS
Identifier: com.TopTest.FCTMACOS
Version: 3.55c (3.55c)
Code Type: X86 (Native)
Parent Process: launchd [132]
Date/Time: 2012-08-03 10:34:35.151 +0800
OS Version: Mac OS X 10.7.3 (11D2001)
Report Version: 9
Interval Since Last Report: 16921 sec
Crashes Since Last Report: 3
Per-App Interval Since Last Report: 5164 sec
Per-App Crashes Since Last Report: 3
Anonymous UUID: 22314E10-99B9-4989-A2E8-53631295027B
Crashed Thread: 4
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000000005a5
VM Regions Near 0x5a5:
--> __PAGEZERO 0000000000000000-0000000000001000 [ 4K] ---/--- SM=NUL /Virgo_FG2_EVT/FCT_MACOS3p55c.app/Contents/MacOS/FCT_MACOS
VM_ALLOCATE 0000000000001000-0000000000013000 [ 72K] ---/--- SM=NUL
Application Specific Information:
objc_msgSend() selector name: isEqual:
objc[575]: garbage collection is OFF
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x964edc22 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x964ed1f6 mach_msg + 70
2 com.apple.CoreFoundation 0x9677ec7a __CFRunLoopServiceMachPort + 170
3 com.apple.CoreFoundation 0x96787da4 __CFRunLoopRun + 1428
4 com.apple.CoreFoundation 0x9678747c CFRunLoopRunSpecific + 332
5 com.apple.CoreFoundation 0x96787328 CFRunLoopRunInMode + 120
6 com.apple.HIToolbox 0x9973417f RunCurrentEventLoopInMode + 318
7 com.apple.HIToolbox 0x9973b4e7 ReceiveNextEventCommon + 381
8 com.apple.HIToolbox 0x9973b356 BlockUntilNextEventMatchingListInMode + 88
9 com.apple.AppKit 0x957dfa9c _DPSNextEvent + 678
10 com.apple.AppKit 0x957df306 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 113
11 com.apple.AppKit 0x957db675 -[NSApplication run] + 911
12 com.apple.AppKit 0x95a6f261 NSApplicationMain + 1054
13 com.TopTest.FCTMACOS 0x00014055 start + 53
Thread 1:: Dispatch queue: com.apple.libdispatch-manager
0 libsystem_kernel.dylib 0x964f090a kevent + 10
1 libdispatch.dylib 0x97c1dc58 _dispatch_mgr_invoke + 969
2 libdispatch.dylib 0x97c1c6a7 _dispatch_mgr_thread + 53
Thread 2:
0 libsystem_kernel.dylib 0x964f0ef2 __sem_wait + 10
1 com.ni.framework.nipalu 0x001ebd0b tTimerTimeWasterSleep::sleep(u64, tTimerTimeUnit, long*) const + 3019
2 com.ni.framework.NI4882 0x06cad33c WaitSRQ + 99996
3 com.ni.framework.nipalu 0x001edc78 tThreadUtility::getCurrentThreadId() + 104
4 libsystem_c.dylib 0x918aeed9 _pthread_start + 335
5 libsystem_c.dylib 0x918b26de thread_start + 34
Thread 3:
0 libsystem_kernel.dylib 0x964edc22 mach_msg_trap + 10
1 libsystem_kernel.dylib 0x964ed1f6 mach_msg + 70
2 com.apple.framework.IOKit 0x982f92df io_connect_method + 465
3 com.apple.framework.IOKit 0x982a9f21 IOConnectCallMethod + 559
4 com.apple.framework.IOKit 0x982aa21b IOConnectCallStructMethod + 84
5 com.ni.framework.nipalu 0x001f11f1 tThreadUtility::yield(iThreadController*, long*) + 12993
6 com.ni.framework.nipalu 0x001ec4b3 tTimerTimeWasterSleep::sleep(u64, tTimerTimeUnit, long*) const + 4979
7 com.ni.framework.NI4882 0x06c9940a WaitSRQ + 18282
8 com.ni.framework.nipalu 0x001edc78 tThreadUtility::getCurrentThreadId() + 104
9 libsystem_c.dylib 0x918aeed9 _pthread_start + 335
10 libsystem_c.dylib 0x918b26de thread_start + 34
Thread 4 Crashed:
0 libobjc.A.dylib 0x915bcd47 objc_msgSend + 23
1 com.apple.CoreFoundation 0x9675b57a CFEqual + 154
2 com.apple.framework.IOKit 0x982cbc80 IOHIDDeviceUnscheduleFromRunLoop + 29
3 com.TopTest.FCTMACOS 0x0008dee2 closeAll + 66
4 com.apple.CoreFoundation 0x967ea298 -[NSObject performSelector:withObject:withObject:] + 72
5 com.TopTest.FCTMACOS 0x000213ff -[TestViewController threadRunTest:] + 2593
6 com.apple.Foundation 0x97ddbe59 -[NSThread main] + 45
7 com.apple.Foundation 0x97ddbe09 __NSThread__main__ + 1582
8 libsystem_c.dylib 0x918aeed9 _pthread_start + 335
9 libsystem_c.dylib 0x918b26de thread_start + 34
Thread 5:
0 libsystem_kernel.dylib 0x964f002e __workq_kernreturn + 10
1 libsystem_c.dylib 0x918b0ccf _pthread_wqthread + 773
2 libsystem_c.dylib 0x918b26fe start_wqthread + 30
Thread 6:
0 libsystem_kernel.dylib 0x964f002e __workq_kernreturn + 10
1 libsystem_c.dylib 0x918b0ccf _pthread_wqthread + 773
2 libsystem_c.dylib 0x918b26fe start_wqthread + 30
Thread 7:
0 libsystem_kernel.dylib 0x964f002e __workq_kernreturn + 10
1 libsystem_c.dylib 0x918b0ccf _pthread_wqthread + 773
2 libsystem_c.dylib 0x918b26fe start_wqthread + 30
Thread 8:
0 libsystem_kernel.dylib 0x964f002e __workq_kernreturn + 10
1 libsystem_c.dylib 0x918b0ccf _pthread_wqthread + 773
2 libsystem_c.dylib 0x918b26fe start_wqthread + 30
Thread 9:
0 libsystem_kernel.dylib 0x964f002e __workq_kernreturn + 10
1 libsystem_c.dylib 0x918b0ccf _pthread_wqthread + 773
2 libsystem_c.dylib 0x918b26fe start_wqthread + 30
Thread 10:
0 libsystem_kernel.dylib 0x964efbb2 __semwait_signal + 10
1 libsystem_c.dylib 0x918637b9 nanosleep$UNIX2003 + 187
2 com.apple.Foundation 0x97e1c05f +[NSThread sleepForTimeInterval:] + 170
3 com.TopTest.FCTMACOS 0x0006cbd7 -[RS232 threadB139RS232Read:] + 223
4 com.apple.Foundation 0x97ddbe59 -[NSThread main] + 45
5 com.apple.Foundation 0x97ddbe09 __NSThread__main__ + 1582
6 libsystem_c.dylib 0x918aeed9 _pthread_start + 335
7 libsystem_c.dylib 0x918b26de thread_start + 34
Thread 4 crashed with X86 Thread State (32-bit):
eax: 0x78690d00 ebx: 0xac7d8724 ecx: 0x96128a48 edx: 0x00000585
edi: 0x7868cc80 esi: 0x78615800 ebp: 0xb0102c18 esp: 0xb0102bf8
ss: 0x00000023 efl: 0x00010206 eip: 0x915bcd47 cs: 0x0000001b
ds: 0x00000023 es: 0x00000023 fs: 0x00000023 gs: 0x0000000f
cr2: 0x000005a5
Logical CPU: 2
...
From the docs;
@param InfoProg
This should be an buffer with at least 8 bytes.
but
uint8_t InfoProg[4];
only consists of 4 uint8_t (bytes). Try increasing your buffer.
User contributions licensed under CC BY-SA 3.0