背景
最后,我们找到了下面的可疑代码,注释掉了这些代码,没有挂起/冻结/沙滩球:
FSRef folderFSRef;
if ( FSFindFolder(kUserDomain, kApplicationSupportFolderType, kCreateFolder, &folderFSRef) != noErr )
{
return false;
}
以下是挂起/冻结时的调用堆栈,简单的测试应用程序,简单的callstack;
Sampling process 13312 for 3 seconds with 1 millisecond of run time between samples<br/> Sampling completed, processing symbols...<br/> Analysis of sampling fooPIPTestApplication (pid 13312) every 1 millisecond<br/> Process: fooPIPTestApplication [13312]<br/> Path: /Users/triger/p4/foopip/main/public/test/macosx/debug/fooPIPTestApplication.app/Contents/MacOS/fooPIPTestApplication<br/> Load Address: 0x100000000<br/> Identifier: com.foo.SimpleTestApplication<br/> Version: ??? (1.0)<br/> Code Type: X86-64 (Native)<br/> Parent Process: debugserver [13310]<br/> <br/> Date/Time: 2013-12-13 19:21:08.875 +0800<br/> OS Version: Mac OS X 10.8.3 (12D78)<br/> Report Version: 7<br/> <br/> Call graph:<br/> 2730 Thread_289593 DispatchQueue_1: com.apple.main-thread (serial)<br/> + 2730 start (in fooPIPTestApplication) + 52 [0x100001714]<br/> + 2730 main (in fooPIPTestApplication) + 398 [0x10000b49e] main.m:121<br/> + 2730 NSApplicationMain (in AppKit) + 869 [0x7fff937c5c06]<br/> + 2730 -[NSApplication run] (in AppKit) + 517 [0x7fff938211d3]<br/> + 2730 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit) + 128 [0x7fff93829e22]<br/> + 2730 _DPSNextEvent (in AppKit) + 685 [0x7fff9382a563]<br/> + 2730 BlockUntilNextEventMatchingListInMode (in HIToolbox) + 62 [0x7fff943fcae3]<br/> + 2730 ReceiveNextEventCommon (in HIToolbox) + 356 [0x7fff943fcc52]<br/> + 2730 RunCurrentEventLoopInMode (in HIToolbox) + 209 [0x7fff943fceb4]<br/> + 2730 CFRunLoopRunSpecific (in CoreFoundation) + 290 [0x7fff8f9100e2]<br/> + 2730 __CFRunLoopRun (in CoreFoundation) + 1078 [0x7fff8f910916]<br/> + 2730 __CFRunLoopServiceMachPort (in CoreFoundation) + 195 [0x7fff8f90b233]<br/> + 2730 mach_msg (in libsystem_kernel.dylib) + 70 [0x7fff8fb65c42]<br/> + 2730 mach_msg_trap (in libsystem_kernel.dylib) + 10 [0x7fff8fb66686]<br/> 2730 Thread_289616 DispatchQueue_2: com.apple.libdispatch-manager (serial)<br/> 2730 _dispatch_mgr_thread (in libdispatch.dylib) + 54 [0x7fff97b839ee]<br/> 2730 _dispatch_mgr_invoke (in libdispatch.dylib) + 883 [0x7fff97b83dea]<br/> 2730 kevent (in libsystem_kernel.dylib) + 10 [0x7fff8fb68d16]<br/> <br/> Total number in stack (recursive counted multiple, when >=5):<br/> <br/> Sort by top of stack, same collapsed (when >= 5):<br/> kevent (in libsystem_kernel.dylib) 2730<br/> mach_msg_trap (in libsystem_kernel.dylib) 2730<br/> <br/> Binary Images:<br/> <br/>
我知道“FSFindFolder”在10.8上已弃用,但我认为这并不意味着它在10.8上有错误
问题:
1.这是FSFindFolder的错误吗?但似乎没有人报道它
2.似乎上面的代码弄乱了一些东西,然后有人稍后遇到它,然后挂起
3.有什么想法吗?
答案 0 :(得分:0)
我认为这是FSFindFolder的一个错误。
我还在https://bugreport.apple.com上打开了一个错误#15664470的错误。到目前为止,没有回复。 :(
我认为这是关于MT安全的。虽然,文件说MT-safe来自10.3。
我已经编写了一个更简单的演示应用程序来验证这个问题
只在辅助线程上调用FSFindFolder,而在主线程中没有任何内容,则应用程序将挂起
如果将它移动到主线程,没问题。
如果用NSFileManager的URLForDirectory替换它:inDomain:properForURL:create:error:,没问题。
Mac10.8和Mac10.6上的结果相同,所以与弃用无关。