Closed daemonx01 closed 9 years ago
Hi, I am happy to take a look at this problem. While it sounds familiar to an issue that was previously brought to my attention, I'm going to ask that you attach a crash report and sample repo to show this behavior. I've updated the contributing guidelines to accurately reflect what I need from you to move forward with this, thanks!
Heres the sample code. While reading file from iPhone, if device detached app crashes.
heres the crash log:
CoreFoundation`CFDataGetLength:
0x7fff99b06a60: pushq %rbp
0x7fff99b06a61: movq %rsp, %rbp
0x7fff99b06a64: pushq %r14
0x7fff99b06a66: pushq %rbx
0x7fff99b06a67: movq %rdi, %rbx
0x7fff99b06a6a: cmpq $-0x1, -0x1cbd00ea(%rip) ; CFCheckForExpandedSet.warnedOnce + 3
0x7fff99b06a72: jne 0x7fff99b06ade ; CFDataGetLength + 126
0x7fff99b06a74: testb $0x1, %bl
0x7fff99b06a77: jne 0x7fff99b06aca ; CFDataGetLength + 106
0x7fff99b06a79: movq (%rbx), %rax
0x7fff99b06a7c: testq %rax, %rax
0x7fff99b06a7f: je 0x7fff99b06ac1 ; CFDataGetLength + 97
0x7fff99b06a81: leaq -0x1cbd0700(%rip), %rcx ; CFConstantStringClassReferencePtr
0x7fff99b06a88: cmpq (%rcx), %rax
0x7fff99b06a8b: je 0x7fff99b06ac1 ; CFDataGetLength + 97
0x7fff99b06a8d: movq -0x1cbd0104(%rip), %rcx ; kCFDataTypeID
0x7fff99b06a94: xorl %r14d, %r14d
0x7fff99b06a97: cmpq $0x3ff, %rcx
0x7fff99b06a9e: ja 0x7fff99b06aab ; CFDataGetLength + 75
0x7fff99b06aa0: leaq -0x1cbd2727(%rip), %rdx ; CFRuntimeObjCClassTable
0x7fff99b06aa7: movq (%rdx,%rcx,8), %r14
0x7fff99b06aab: cmpq %r14, %rax
0x7fff99b06aae: je 0x7fff99b06ac1 ; CFDataGetLength + 97
0x7fff99b06ab0: testb $0x1, %al
0x7fff99b06ab2: je 0x7fff99b06aca ; CFDataGetLength + 106
0x7fff99b06ab4: movq %rbx, %rdi
0x7fff99b06ab7: callq 0x7fff99ca6d7a ; symbol stub for: object_getClass
0x7fff99b06abc: cmpq %r14, %rax
0x7fff99b06abf: jne 0x7fff99b06aca ; CFDataGetLength + 106
0x7fff99b06ac1: movq 0x10(%rbx), %rax
0x7fff99b06ac5: popq %rbx
0x7fff99b06ac6: popq %r14
0x7fff99b06ac8: popq %rbp
0x7fff99b06ac9: retq
0x7fff99b06aca: movq -0x1cbde021(%rip), %rsi ; "length"
0x7fff99b06ad1: movq %rbx, %rdi
0x7fff99b06ad4: popq %rbx
0x7fff99b06ad5: popq %r14
0x7fff99b06ad7: popq %rbp
0x7fff99b06ad8: jmpq -0x1cc218be(%rip) ; (void )0x00007fff97b900c0: objc_msgSend
0x7fff99b06ade: leaq -0x1cbd015d(%rip), %rdi ; CFDataGetTypeID.initOnce
0x7fff99b06ae5: leaq -0x1cc1f23c(%rip), %rsi ; __block_literal_global
0x7fff99b06aec: callq 0x7fff99ca7098 ; symbol stub for: dispatch_once
0x7fff99b06af1: jmp 0x7fff99b06a74 ; CFDataGetLength + 20
0x7fff99b06af3: nopw %cs:(%rax,%rax)
crash comes on this line in the library:
case SDMMD_AFC_Packet_GetFileInfo: {
bool should_parse = false;
CFIndex data_length = CFDataGetLength((*operation)->ivars.packet->response);
if (data_length == sizeof(uint64_t)) {
uint64_t response;
memcpy(&response, CFDataGetBytePtr((*operation)->ivars.packet->response), data_length);
if (response != 8 && response != 4) {
// this file can be accessed.
should_parse = true;
}
}
line : CFIndex data_length = CFDataGetLength((*operation)->ivars.packet->response);
Similarly if i try to fix it with null checks, there comes more crashes in other functions and thread.
I would like to have a reproducible case to test this against to determine if this is the issue i'm thinking of (accessing a bad file descriptor) or something new.
Please look at the CONTIBUTING.md file for guidelines on the requested materials. what you have posted here aren't crash logs, they are the disassembly of where it stopped. You will have to run the code outside of Xcode without a debugger attached to have it generate a crash log. You can find crash logs by opening the Console.app and looking under "User Diagnostic Reports".
Thanks!
Thank you for replying and letting me know the correct method to find crash logs.
here it is: https://gist.github.com/bilawal230/71d68fba5017f96a9138
here's the sample project, it's same as i posted before if you detach device while reading file from device, it will crash.
https://www.dropbox.com/s/f8cpqfhf176jvgt/SDMMDSAMPLE.zip?dl=0
here's the crash log:
Process: iPhoneTestIOSCocoa [59982] Path: /Users/USER/Library/Developer/Xcode/DerivedData/iPhoneTestIOS-cytiiwmduaicxafcymnrihmiloyk/Build/Products/Debug/iPhoneTestIOSCocoa.app/Contents/MacOS/iPhoneTestIOSCocoa Identifier: com.sc.iPhoneTestIOSCocoa Version: 1.0 (1) Code Type: X86-64 (Native) Parent Process: ??? [1] Responsible: iPhoneTestIOSCocoa [59982] User ID: 503
Date/Time: 2015-07-30 16:40:46.224 +0500 OS Version: Mac OS X 10.10.1 (14B25) Report Version: 11 Anonymous UUID: 7FA63A4F-771A-4CAE-C525-AB70CCB79251
Sleep/Wake UUID: E36A41C2-85DE-457C-8D23-08E9D19A70A2
Time Awake Since Boot: 77000 seconds Time Since Wake: 1500 seconds
Crashed Thread: 0 Dispatch queue: com.samdmarshall.sdmmobiledevice.afc.b8cf53aaec1ca4073c72b997837714bf98f7e312.2015-07-30*16:40:37
Exception Type: EXC_BAD_ACCESS (SIGSEGV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Regions Near 0: --> __TEXT 0000000109d82000-0000000109ddf000 [ 372K] r-x/rwx SM=COW /Users/USER/Library/Developer/Xcode/DerivedData/iPhoneTestIOS-cytiiwmduaicxafcymnrihmiloyk/Build/Products/Debug/iPhoneTestIOSCocoa.app/Contents/MacOS/iPhoneTestIOSCocoa
Thread 0 Crashed:: Dispatch queue: com.samdmarshall.sdmmobiledevice.afc.b8cf53aaec1ca4073c72b997837714bf98f7e312.2015-07-30_16:40:37 0 com.apple.CoreFoundation 0x00007fff99b06a79 CFDataGetLength + 25 1 com.sc.iPhoneTestIOSCocoa 0x0000000109dc2a49 SDMMD_AFCProcessOperation_block_invoke + 345 (SDMMD_AppleFileConduit.c:268) 2 libdispatch.dylib 0x00007fff8dfeec13 _dispatch_client_callout + 8 3 libdispatch.dylib 0x00007fff8dfefe5e _dispatch_barrier_sync_f_invoke + 57 4 com.sc.iPhoneTestIOSCocoa 0x0000000109dc28bc SDMMD_AFCProcessOperation + 140 (SDMMD_AppleFileConduit.c:231) 5 com.sc.iPhoneTestIOSCocoa 0x0000000109d84f58 AFCFileDescriptorReadByPathOperationUsingSeek + 184 (iPhoneTestAFC.c:328) 6 com.sc.iPhoneTestIOSCocoa 0x0000000109d8767b AFCFileDescriptorReadDir + 7963 (iPhoneTestAFC.c:997) 7 com.sc.iPhoneTestIOSCocoa 0x0000000109db1c53 fetchMediaJson + 83 (iPhoneTestIOS.c:2182) 8 com.sc.iPhoneTestIOSCocoa 0x0000000109da46fc -[AppDelegate applicationDidFinishLaunching:] + 172 (AppDelegate.m:65) 9 com.apple.CoreFoundation 0x00007fff99bfecbc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER + 12 10 com.apple.CoreFoundation 0x00007fff99af01b4 _CFXNotificationPost + 3140 11 com.apple.Foundation 0x00007fff8b07dea1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66 12 com.apple.AppKit 0x00007fff8e04410b -[NSApplication _postDidFinishNotification] + 291 13 com.apple.AppKit 0x00007fff8e043e76 -[NSApplication _sendFinishLaunchingNotification] + 191 14 com.apple.AppKit 0x00007fff8e040c76 -[NSApplication(NSAppleEventHandling) _handleAEOpenEvent:] + 574 15 com.apple.AppKit 0x00007fff8e0406b5 -[NSApplication(NSAppleEventHandling) _handleCoreEvent:withReplyEvent:] + 244 16 com.apple.Foundation 0x00007fff8b09d458 -[NSAppleEventManager dispatchRawAppleEvent:withRawReply:handlerRefCon:] + 290 17 com.apple.Foundation 0x00007fff8b09d2c9 NSAppleEventManagerGenericHandler + 102 18 com.apple.AE 0x00007fff9509d99c aeDispatchAppleEvent(AEDesc const, AEDesc, unsigned int, unsigned char) + 531 19 com.apple.AE 0x00007fff9509d719 dispatchEventAndSendReply(AEDesc const, AEDesc) + 31 20 com.apple.AE 0x00007fff9509d623 aeProcessAppleEvent + 295 21 com.apple.HIToolbox 0x00007fff8b4ee37e AEProcessAppleEvent + 56 22 com.apple.AppKit 0x00007fff8e03cd76 _DPSNextEvent + 2665 23 com.apple.AppKit 0x00007fff8e03be80 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 194 24 com.apple.AppKit 0x00007fff8e02fe23 -[NSApplication run] + 594 25 com.apple.AppKit 0x00007fff8e01b2d4 NSApplicationMain + 1832 26 com.sc.iPhoneTestIOSCocoa 0x0000000109daad02 main + 34 (main.m:13) 27 libdyld.dylib 0x00007fff982105c9 start + 1
Thread 1:: Dispatch queue: com.apple.libdispatch-manager 0 libsystem_kernel.dylib 0x00007fff996a422e kevent64 + 10 1 libdispatch.dylib 0x00007fff8dff1a6a _dispatch_mgr_thread + 52
Thread 2: 0 libsystem_kernel.dylib 0x00007fff996a3946 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x00007fff994b94a1 start_wqthread + 13
Thread 3: 0 libsystem_kernel.dylib 0x00007fff996a3946 __workq_kernreturn + 10 1 libsystem_pthread.dylib 0x00007fff994b94a1 start_wqthread + 13
Thread 4:: Dispatch queue: com.samdmarshall.sdmmobiledevice.socketQueue 0 libcrypto.0.9.8.dylib 0x00007fff9a470aa1 BIO_free_all + 1 1 libssl.0.9.8.dylib 0x0000000109e40258 SSL_free + 152 2 com.sc.iPhoneTestIOSCocoa 0x0000000109db99ea SDMMD_AMDeviceRefFinalize + 138 (SDMMD_AMDevice_Class.c:69) 3 com.apple.CoreFoundation 0x00007fff99af8a0e CFRelease + 526 4 com.apple.CoreFoundation 0x00007fff99b1973d -[NSArrayI dealloc] + 125 5 libobjc.A.dylib 0x00007fff97bae68c objc_object::sidetable_release(bool) + 236 6 com.apple.CoreFoundation 0x00007fff99af8930 CFRelease + 304 7 com.sc.iPhoneTestIOSCocoa 0x0000000109d89823 CFSafeRelease + 35 (CFTypeAddition.c:338) 8 com.sc.iPhoneTestIOSCocoa 0x0000000109db810b SDMMD_USBMuxDetachedCallback + 331 (SDMMD_USBMuxListener.c:170) 9 com.sc.iPhoneTestIOSCocoa 0x0000000109db95c5 SDMMD_USBMuxStartListener_block_invoke_2 + 437 (SDMMD_USBMuxListener.c:384) 10 libdispatch.dylib 0x00007fff8dfeec13 _dispatch_client_callout + 8 11 libdispatch.dylib 0x00007fff8dff987e _dispatch_source_latch_and_call + 721 12 libdispatch.dylib 0x00007fff8dff262b _dispatch_source_invoke + 412 13 libdispatch.dylib 0x00007fff8dff2154 _dispatch_queue_drain + 571 14 libdispatch.dylib 0x00007fff8dff3ecc _dispatch_queue_invoke + 202 15 libdispatch.dylib 0x00007fff8dff16b7 _dispatch_root_queue_drain + 463 16 libdispatch.dylib 0x00007fff8dffffe4 _dispatch_worker_thread3 + 91 17 libsystem_pthread.dylib 0x00007fff994bb6cb _pthread_wqthread + 729 18 libsystem_pthread.dylib 0x00007fff994b94a1 start_wqthread + 13
Thread 0 crashed with X86 Thread State (64-bit): rax: 0x00007fff55e7c488 rbx: 0x0000000000000000 rcx: 0x0000000000000000 rdx: 0x0000000109dc2a2a rdi: 0x0000000000000000 rsi: 0x0000000000000009 rbp: 0x00007fff55e7c3b0 rsp: 0x00007fff55e7c3a0 r8: 0x0000000000000300 r9: 0xbaddc0dedeadbead r10: 0x00007fac2a8631b0 r11: 0x0000000000000001 r12: 0x00006080000f4010 r13: 0x00000000000f42a7 r14: 0x00007fff7b254780 r15: 0x0000000109de1ef0 rip: 0x00007fff99b06a79 rfl: 0x0000000000010246 cr2: 0x0000000000000000
Logical CPU: 0 Error Code: 0x00000004 Trap Number: 14
Binary Images:
0x109d82000 - 0x109ddefff +com.sc.iPhoneTestIOSCocoa (1.0 - 1) <270E429E-F71E-3F30-97AD-06FEE5BB68A5> /Users/USER/Library/Developer/Xcode/DerivedData/iPhoneTestIOS-cytiiwmduaicxafcymnrihmiloyk/Build/Products/Debug/iPhoneTestIOSCocoa.app/Contents/MacOS/iPhoneTestIOSCocoa
0x109e1d000 - 0x109e52ff7 libssl.0.9.8.dylib (52) <70680606-475F-3C89-BB5F-E274253DC7C6> /usr/lib/libssl.0.9.8.dylib
0x10e046000 - 0x10e046ff5 +cl_kernels (???) <95EE2695-8054-4B09-A214-973BB2CB44D1> cl_kernels
0x10e048000 - 0x10e12efef unorm8_bgra.dylib (2.4.5) <90797750-141F-3114-ACD0-A71363968678> /System/Library/Frameworks/OpenCL.framework/Versions/A/Libraries/ImageFormats/unorm8_bgra.dylib
0x10e1f5000 - 0x10e1f5fff +cl_kernels (???) <0CAA1706-E45E-43D3-A1F7-D899009E6E5E> cl_kernels
0x7fff652cc000 - 0x7fff65302837 dyld (353.2.1) <4696A982-1500-34EC-9777-1EF7A03E2659> /usr/lib/dyld
0x7fff8ac1a000 - 0x7fff8ad31fe7 libvDSP.dylib (512) <52777555-F051-3BC2-A2D2-9645907E836D> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
0x7fff8ad32000 - 0x7fff8adc7ff7 com.apple.ColorSync (4.9.0 - 4.9.0)
External Modification Summary: Calls made by other processes targeting this process: task_for_pid: 1 thread_create: 0 thread_set_state: 0 Calls made by this process: task_for_pid: 0 thread_create: 0 thread_set_state: 0 Calls made by all processes on this machine: task_for_pid: 268665 thread_create: 0 thread_set_state: 3778
VM Region Summary: ReadOnly portion of Libraries: Total=182.7M resident=111.2M(61%) swapped_out_or_unallocated=71.5M(39%) Writable regions: Total=140.0M written=65.9M(47%) resident=71.5M(51%) swapped_out=8K(0%) unallocated=68.5M(49%)
REGION TYPE VIRTUAL =========== ======= CG backing stores 968K CG image 24K CG shared images 240K CoreAnimation 20K CoreImage 8K CoreUI image data 60K Foundation 4K Kernel Alloc Once 8K MALLOC 112.0M MALLOC (admin) 32K Memory Tag 242 12K Memory Tag 251 8K OpenCL 16K STACK GUARD 56.0M Stack 9824K VM_ALLOCATE 17.1M DATA 15.5M IMAGE 528K LINKEDIT 70.5M TEXT 112.2M __UNICODE 544K mapped file 61.1M shared memory 4K =========== ======= TOTAL 456.4M
Does this sample contain the changes that resolved the other issue? I want to make sure that I'm not working from an older version of the code.
No, here's the new sample with latest version of library.
https://www.dropbox.com/s/l63xtpgfxfxf5dn/SDMMobileDevice%20SAMPLE%202.zip?dl=0
And here's the new crash log from latest library.
While reading a large file, say 500mb, if you detach the device app will crash. It happens whenever in the reading process.
can you look into it this weekend?
Can you please try again with the latest commit? I haven't been able to reproduce since adding those fixes.
Yes, it's fixed now after added checks. Thanks a lot
Hi All,
Could you please share the code. i want to see the reading process using it. Please help.
Thanks.
While reading data from the iPhone, if the device is detached the application crashes immediately.
Is there not any exception or crash handling? How to prevent it? Application shouldn't crash but give error instead. There seems to be problem with it.