Compiler Crash in Xcode 11.x (SILLinkerVisitor::visitProtocolConformance)

Hi Folks,

I'm experiencing a compiler crash on a large project, which occurs only when archiving my target (not in debug builds). I'm looking for some guidance as to how I can further debug the cause of the crash.

I was hopeful that the issues mentioned in the Xcode 11.5 release notes might have been the cause, but it reproduces in 11.5 as well. Xcode 11.3 does not seem to reproduce the issue.

At the moment, when the compiler segfaults, it gives me the following stack trace:

While running pass #2022759 SILModuleTransform "PerformanceSILLinker".
0 swift 0x00000001115674ea PrintStackTraceSignalHandler(void*) + 42
1 swift 0x0000000111566cc0 SignalHandler(int) + 352
2 libsystem_platform.dylib 0x00007fff6a7dd5fd _sigtramp + 29
3 libsystem_platform.dylib 000000000000000000 _sigtramp + 2508335648
4 swift 0x000000010dbff165 swift::SILLinkerVisitor::visitProtocolConformance(swift::ProtocolConformanceRef, llvm::Optionalswift::SILDeclRef const&) + 197
5 swift 0x000000010dbfeac9 swift::SILLinkerVisitor::processFunction(swift::SILFunction*) + 825
6 swift 0x000000010dad1740 (anonymous namespace)::SILLinker::run() + 304
7 swift 0x000000010d9c2d09 swift::SILPassManager::execute() + 2329
8 swift 0x000000010d5c74c8 swift::CompilerInstance::performSILProcessing(swift::SILModule*, swift::UnifiedStatsReporter*) + 7912
9 swift 0x000000010d2c3070 performCompileStepsPostSILGen(swift::CompilerInstance&, swift::CompilerInvocation&, std::__1::unique_ptr<swift::SILModule, std::__1::default_deleteswift::SILModule >, bool, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, bool, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 1712
10 swift 0x000000010d2bab95 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 55813
11 swift 0x000000010d230b73 main + 1283
12 libdyld.dylib 0x00007fff6a5e4cc9 start + 1

I have tried using alternate toolchains, ex. Swift 5.2.4 Release 2020-05-18 (a), to get more debugging info, but they seem to turn up a number of compilation failures that I don't experience for the toolchain as it ships in Xcode 11.5. For instance, one of the watchOS targets fails with "unsupported target architecture: 'arm64_32'", and after removing that target, I get a number of failures in ObjC block syntax ("Incompatible block pointer types..."). Not sure how the open source toolchain would differ in these cases.

Thanks for any help!

FYI, opened a Swift bug here as a placeholder:

1 Like

Could you attach a reproducer to your bug ticket? It doesn't necessarily have to be the entire project, if you can minimise it that would be great. Keep in mind that any code you attach would be visible to everyone else so if you don't want everyone else to see it then you could send it via feedback instead so only Apple folks can see it.

Thanks - I'm hoping to narrow down the cause first, as it's a very large project. The stack trace isnt providing much info.

Another bit of info: this seems to reproduce both when optimizing for size (-Osize) and speed (-O). It does not occur when optimizations are off (-Onone).

Hmm, perhaps you can try disabling this optimisation pass in the meantime by passing -Xllvm -sil-disable-pass=performance-linker (you need to add it to "Other Swift Flags" for Release mode) and see if that fixes the issue.

You can also try passing -Xfrontend -sil-verify-all to figure out if there's another optimisation pass that's causing a problem instead.

1 Like

Many thanks Suyash! That turned up more info that led to a workaround. I'll do my best to workout a smaller repro case now.

1 Like

I've updated the issue with a small code sample that can reproduce the crash.

1 Like