How to debug Xcode: "An internal error occurred. Source editor functionality is limited"


(Jesse Grosjean) #1

Recently autocomplete, syntax highlighting, and auto-indent have stopped
working (or work for a few minutes then break) in my Swift 3.1 Xcode 8.3.1
project. The project compiles without any warnings.

I guess this is all due to problems that the SourceKitService has with my
code? I notice lots (around 30 all in last few minutes) of SourceKitService
crash logs all with the same crash stack (Included at end of this email).

My question is... what's the best way to find the problem?

Does anyone recognize the below stack and know what might be causing that
particular crash? Is there any way to log what file the SourceKitService is
working on, so I can see what it's doing before the crash?

Thanks,
Jesse

Crashed Thread: 6

Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY

Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [0]

VM Regions Near 0:
-->
    __TEXT 000000010cbd9000-000000010ecd0000 [ 33.0M]
r-x/rwx SM=COW
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/sourcekitd.framework/Versions/A/XPCServices/SourceKitService.xpc/Contents/MacOS/SourceKitService

Thread 6 Crashed:
0 com.apple.SourceKitService.802.0.51 0x000000010d4c265d
swift::ClassDecl::inheritsSuperclassInitializers(swift::LazyResolver*) + 589
1 com.apple.SourceKitService.802.0.51 0x000000010d437589
lookupObjCMethodInType(swift::Type, swift::ObjCSelector, bool, bool,
swift::SourceManager&, bool) + 217
2 com.apple.SourceKitService.802.0.51 0x000000010d4368e2
swift::ASTContext::diagnoseUnintendedObjCMethodOverrides(swift::SourceFile&)
+ 1138
3 com.apple.SourceKitService.802.0.51 0x000000010d3d8b20
swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&,
swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int,
unsigned int) + 4416
4 com.apple.SourceKitService.802.0.51 0x000000010cd6b0b6
swift::CompilerInstance::performSema() + 5334
5 com.apple.SourceKitService.802.0.51 0x000000010cc4fca5
SourceKit::SwiftLangSupport::indexSource(llvm::StringRef,
SourceKit::IndexingConsumer&, llvm::ArrayRef<char const*>, llvm::StringRef)
+ 6037
6 com.apple.SourceKitService.802.0.51 0x000000010cc6c712 void
SourceKit::WorkQueue::DispatchData::callAndDelete<handleRequestImpl(void*,
std::__1::function<void (void*)>)::$_3>(void*) + 3250
7 libdispatch.dylib 0x00007fff9be788fc
_dispatch_client_callout + 8
8 libdispatch.dylib 0x00007fff9be8cccd
_dispatch_block_invoke_direct + 322
9 com.apple.SourceKitService.802.0.51 0x000000010eabae3f
executeBlock(void*) + 15
10 com.apple.SourceKitService.802.0.51 0x000000010ccdb74d
ExecuteOnThread_Dispatch(void*) + 13
11 libsystem_pthread.dylib 0x00007fff9c0c79af _pthread_body + 180
12 libsystem_pthread.dylib 0x00007fff9c0c78fb _pthread_start + 286
13 libsystem_pthread.dylib 0x00007fff9c0c7101 thread_start + 13