极其简单的项目在编译时使 Xcode 崩溃
Posted
技术标签:
【中文标题】极其简单的项目在编译时使 Xcode 崩溃【英文标题】:Extremely simple project crashes Xcode at compile time 【发布时间】:2014-05-28 15:45:23 【问题描述】:我不是世界上最有经验的程序员,所以在我提交错误之前,我想知道我是否在这里做了一些愚蠢的事情。
This project 在编译时在 Xcode 5.1.1 (5B1008) 和 Xcode 6.0 (6A215l) 上崩溃。 FWIW,在 Xcode 6 中创建新项目不会再自动将 .pch 文件添加到项目中......
Process: Xcode [17263]
Path: /Applications/Xcode.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 5.1.1 (5085)
Build Info: IDEFrameworks-5085000000000000~10
App Item ID: 497799835
App External ID: 520942841
Code Type: X86-64 (Native)
Parent Process: launchd [180]
Responsible: Xcode [17263]
User ID: 503
PlugIn Path: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libclang.dylib
PlugIn Identifier: libclang.dylib
PlugIn Version: ??? (503.0.40)
Date/Time: 2014-05-11 22:04:11.818 +0200
OS Version: Mac OS X 10.9.2 (13C1021)
Report Version: 11
Anonymous UUID: 5F0DE60E-4FAE-AAC4-8BB3-B2A90D648B2A
Crashed Thread: 5 Dispatch queue: IDEIndex PCH Creation Lock
Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000106a21000
VM Regions Near 0x106a21000:
Stack 000000010699f000-0000000106a21000 [ 520K] rw-/rwx SM=COW thread 5
--> STACK GUARD 0000000106a21000-0000000106a22000 [ 4K] ---/rwx SM=NUL stack guard for thread 6
Stack 0000000106a22000-0000000106aa4000 [ 520K] rw-/rwx SM=COW thread 6
Application Specific Information:
ProductBuildVersion: 5B1008
Thread 0:: Dispatch queue: com.apple.main-thread
0 libsystem_kernel.dylib 0x00007fff8db72a1a mach_msg_trap + 10
1 libsystem_kernel.dylib 0x00007fff8db71d18 mach_msg + 64
2 com.apple.CoreFoundation 0x00007fff95687fc5 __CFRunLoopServiceMachPort + 181
3 com.apple.CoreFoundation 0x00007fff956875e9 __CFRunLoopRun + 1161
4 com.apple.CoreFoundation 0x00007fff95686f25 CFRunLoopRunSpecific + 309
5 com.apple.HIToolbox 0x00007fff96684a0d RunCurrentEventLoopInMode + 226
6 com.apple.HIToolbox 0x00007fff966847b7 ReceiveNextEventCommon + 479
7 com.apple.HIToolbox 0x00007fff966845bc _BlockUntilNextEventMatchingListInModeWithFilter + 65
8 com.apple.AppKit 0x00007fff96bc33de _DPSNextEvent + 1434
9 com.apple.AppKit 0x00007fff96bc2a2b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
10 com.apple.dt.DVTKit 0x0000000101262631 -[DVTApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 84
11 com.apple.AppKit 0x00007fff96bb6b2c -[NSApplication run] + 553
12 com.apple.AppKit 0x00007fff96ba1913 NSApplicationMain + 940
13 libdyld.dylib 0x00007fff8be105fd start + 1
Thread 5 Crashed:: Dispatch queue: IDEIndex PCH Creation Lock
0 libclang.dylib 0x0000000102c6d0d9 void llvm::BitstreamWriter::EmitRecordWithAbbrevImpl<unsigned long long>(unsigned int, llvm::SmallVectorImpl<unsigned long long>&, llvm::StringRef) + 809
1 libclang.dylib 0x0000000102c6c867 void llvm::BitstreamWriter::EmitRecord<unsigned long long>(unsigned int, llvm::SmallVectorImpl<unsigned long long>&, unsigned int) + 71
2 libclang.dylib 0x0000000102d90f25 clang::ASTWriter::WriteASTCore(clang::Sema&, llvm::StringRef, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, clang::Module*) + 35045
3 libclang.dylib 0x0000000102d8860e clang::ASTWriter::WriteAST(clang::Sema&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, clang::Module*, llvm::StringRef, bool) + 6830
4 libclang.dylib 0x0000000102c189a3 clang::ASTUnit::Save(llvm::StringRef) + 691
5 libclang.dylib 0x0000000102b9074f clang_saveTranslationUnit + 543
6 com.apple.dt.IDEFoundation 0x00000001016663af -[IDEIndexClangTranslationUnit cxTranslationUnit] + 331
7 com.apple.dt.IDEFoundation 0x00000001017cc11a +[IDEIndexClangDataSource translationUnitForPCHFile:arguments:session:create:] + 259
8 com.apple.dt.IDEFoundation 0x0000000101895552 __90-[IDEIndex createPCHFile:arguments:hashCriteria:target:session:willIndex:translationUnit:]_block_invoke + 1739
9 libdispatch.dylib 0x00007fff948102ad _dispatch_client_callout + 8
10 libdispatch.dylib 0x00007fff94811166 _dispatch_barrier_sync_f_invoke + 39
11 com.apple.dt.DVTFoundation 0x0000000100b705cf -[DVTDispatchLock performLockedBlock:] + 95
12 com.apple.dt.IDEFoundation 0x0000000101894932 -[IDEIndex createPCHFile:arguments:hashCriteria:target:session:willIndex:translationUnit:] + 919
13 com.apple.dt.IDEFoundation 0x00000001016501f1 -[IDEIndexClangQueryProvider _createSharedTranslationUnitWithCurrentFileContentDictionary:index:] + 2601
14 com.apple.dt.IDEFoundation 0x0000000101742414 __98-[IDEIndexClangQueryProvider codeDiagnosticsAtLocation:withCurrentFileContentDictionary:forIndex:]_block_invoke + 39
15 libdispatch.dylib 0x00007fff948102ad _dispatch_client_callout + 8
16 libdispatch.dylib 0x00007fff94811166 _dispatch_barrier_sync_f_invoke + 39
17 com.apple.dt.DVTFoundation 0x0000000100b705cf -[DVTDispatchLock performLockedBlock:] + 95
18 com.apple.dt.IDEFoundation 0x000000010164f693 -[IDEIndexClangQueryProvider performClang:] + 140
19 com.apple.dt.IDEFoundation 0x0000000101655579 -[IDEIndexClangQueryProvider codeDiagnosticsAtLocation:withCurrentFileContentDictionary:forIndex:] + 634
20 com.apple.dt.IDEFoundation 0x00000001016552bd -[IDEIndex(IDEIndexQueries) codeDiagnosticsAtLocation:withCurrentFileContentDictionary:] + 109
21 com.apple.dt.IDE.IDESourceEditor 0x0000000107369727 __96-[IDEClangDiagnosticController _generateDiagnosticsForDocumentLocation:context:completionBlock:]_block_invoke + 462
22 com.apple.dt.DVTFoundation 0x0000000100baf617 -[DVTOperation main] + 48
23 com.apple.Foundation 0x00007fff8dfbd8a1 -[__NSOperationInternal _start:] + 631
24 com.apple.Foundation 0x00007fff8dfbd54b __NSOQSchedule_f + 64
25 libdispatch.dylib 0x00007fff948102ad _dispatch_client_callout + 8
26 libdispatch.dylib 0x00007fff9481268f _dispatch_queue_drain + 451
27 libdispatch.dylib 0x00007fff948139dd _dispatch_queue_invoke + 110
28 libdispatch.dylib 0x00007fff94811fa3 _dispatch_root_queue_drain + 75
29 libdispatch.dylib 0x00007fff94813193 _dispatch_worker_thread2 + 40
30 libsystem_pthread.dylib 0x00007fff94362ef8 _pthread_wqthread + 314
31 libsystem_pthread.dylib 0x00007fff94365fb9 start_wqthread + 13
【问题讨论】:
有趣的是,您的项目在 XCode 5.0.1 下编译,并在 "MY_DEBUG(@"standard error: %@ %@ %@",self.path, self.arguments, s_err);" 【参考方案1】:您的项目有几个错误。为了解决这个问题,我将逐步编写。
关闭您的项目 直接打开您的文件 test-Prefix.pch 并注释 #import "../../myStuff.h" 行 保存文件并打开您的项目 将 3 个文件(myStuff.h、UTTask.h 和 UTTask.m)添加到您的主要目标 在 myStuff.h 中将 #import "UTTask.m" 行更改为 #import "UTTask.h" 将 test-Prefix.pch 的内容替换为#ifdef __OBJC__ #import <Cocoa/Cocoa.h> #import "myStuff.h" #endif
那么你有一个未定义的 MY_DEBUG() 方法的问题,所以注释它(3 行),而你还没有定义它。
这可能行得通。
【讨论】:
以上是关于极其简单的项目在编译时使 Xcode 崩溃的主要内容,如果未能解决你的问题,请参考以下文章
在 Xcode 6 中运行 cpp-netlib - 编译但运行时崩溃
Xcode编写SwiftUI代码时一个编译通过但导致预览(Preview)崩溃的小陷阱
Xcode编写SwiftUI代码时一个编译通过但导致预览(Preview)崩溃的小陷阱