[swift-users] Segmentation fault: 11 after updating codebase to Swift 3.0

Joe Groff jgroff at apple.com
Fri Oct 21 16:29:55 CDT 2016


We discovered a problem recently where we would miscompile when imported ObjC lightweight generic classes are extended to conform to Swift protocols. This is being tracked by Apple as rdar://problem/28873860 <rdar://problem/28873860>, for reference, and should be release noted in upcoming Xcode seeds. If you happen to be extending any ObjC generic classes to conform to Swift protocols, there are a couple of workarounds that may work:

- making the protocol @objc, if possible, or
- wrapping the ObjC class reference in a generic struct, and making that struct conform to the protocol instead of the class.

Does that help at all?

-Joe

> On Oct 21, 2016, at 9:44 AM, Evan Maloney via swift-users <swift-users at swift.org> wrote:
> 
> This is definitely not my first time hitting Swift compiler crashes :)
> 
> In the past, the stack traces have been helpful, pointing to what code the compiler was working on when it crashed. Unfortunately, this latest crash doesn't fall into that category:
> 
> CompileSwift normal x86_64 /Users/emaloney/Documents/Code/CleanroomProject/AppleTart/Sources/iOS/FormBuilder/Row.swift
>     cd /Users/emaloney/Documents/Code/CleanroomProject/AppleTart
>     /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -filelist /var/folders/gn/gt76_ktx7w1010xg4v68p3txynz8ws/T/sources-a27d97 -primary-file /Users/emaloney/Documents/Code/CleanroomProject/AppleTart/Sources/iOS/FormBuilder/Row.swift -target x86_64-apple-ios9.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk -I /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Products/Debug-iphonesimulator -F /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Products/Debug-iphonesimulator -F /Users/emaloney/Documents/Code/CleanroomProject/AppleTart/Carthage/Checkouts/AppleApiDocClients/build/Debug -F /Users/emaloney/Documents/Code/CleanroomProject/AppleTart/Carthage/Checkouts/AppleTapstreamClient/build/Debug -F /Users/emaloney/Documents/Code/CleanroomProject/AppleTart/Carthage/Checkouts/PromiseKit/build/Debug -enable-testing -g -import-objc-header /Users/emaloney/Documents/Code/CleanroomProject/AppleTart/BuildControl/Bridging-Header.h -module-cache-path /Users/emaloney/Library/Developer/Xcode/DerivedData/ModuleCache -D DEBUG -serialize-debugging-options -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/AppleTart-generated-files.hmap -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/AppleTart-own-target-headers.hmap -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/AppleTart-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/AppleTart-project-headers.hmap -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Products/Debug-iphonesimulator/CardIO.framework/Headers -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/DerivedSources/x86_64 -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/emaloney/Documents/Code/CleanroomProject/AppleTart -emit-module-doc-path /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/Objects-normal/x86_64/Row~partial.swiftdoc -Onone -module-name AppleTart -emit-module-path /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/Objects-normal/x86_64/Row~partial.swiftmodule -serialize-diagnostics-path /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/Objects-normal/x86_64/Row.dia -emit-dependencies-path /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/Objects-normal/x86_64/Row.d -emit-reference-dependencies-path /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/Objects-normal/x86_64/Row.swiftdeps -o /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/Objects-normal/x86_64/Row.o
> 
> 0  swift                    0x000000010e668b6d PrintStackTraceSignalHandler(void*) + 45
> 1  swift                    0x000000010e6685b6 SignalHandler(int) + 470
> 2  libsystem_platform.dylib 0x00007fff94a7b52a _sigtramp + 26
> 3  libsystem_platform.dylib 0x0000000000000004 _sigtramp + 1800948468
> 4  swift                    0x000000010baa58d2 llvm::Value* llvm::function_ref<llvm::Value* (unsigned int)>::callback_fn<swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*)::$_0>(long, unsigned int) + 530
> 5  swift                    0x000000010bb83600 swift::irgen::emitImpliedWitnessTableRef(swift::irgen::IRGenFunction&, llvm::ArrayRef<swift::irgen::ProtocolEntry>, swift::ProtocolDecl*, llvm::function_ref<llvm::Value* (unsigned int)> const&) + 240
> 6  swift                    0x000000010baa56a7 swift::irgen::emitArchetypeWitnessTableRef(swift::irgen::IRGenFunction&, swift::CanTypeWrapper<swift::ArchetypeType>, swift::ProtocolDecl*) + 247
> 7  swift                    0x000000010bb7f9cd swift::SILWitnessVisitor<(anonymous namespace)::WitnessTableBuilder>::visitProtocolDecl(swift::ProtocolDecl*) + 5997
> 8  swift                    0x000000010bb7d4d7 swift::irgen::IRGenModule::emitSILWitnessTable(swift::SILWitnessTable*) + 503
> 9  swift                    0x000000010baef8ed swift::irgen::IRGenerator::emitGlobalTopLevel() + 2077
> 10 swift                    0x000000010bbb0fcb performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1259
> 11 swift                    0x000000010ba7f1c7 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*) + 23687
> 12 swift                    0x000000010ba77265 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 17029
> 13 swift                    0x000000010ba3482d main + 8685
> 14 libdyld.dylib            0x00007fff8ab5c5ad start + 1
> Stack dump:
> 0.	Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c -filelist /var/folders/gn/gt76_ktx7w1010xg4v68p3txynz8ws/T/sources-a27d97 -primary-file /Users/emaloney/Documents/Code/CleanroomProject/AppleTart/Sources/iOS/FormBuilder/Row.swift -target x86_64-apple-ios9.0 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk -I /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Products/Debug-iphonesimulator -F /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Products/Debug-iphonesimulator -F /Users/emaloney/Documents/Code/CleanroomProject/AppleTart/Carthage/Checkouts/AppleApiDocClients/build/Debug -F /Users/emaloney/Documents/Code/CleanroomProject/AppleTart/Carthage/Checkouts/AppleTapstreamClient/build/Debug -F /Users/emaloney/Documents/Code/CleanroomProject/AppleTart/Carthage/Checkouts/PromiseKit/build/Debug -enable-testing -g -import-objc-header /Users/emaloney/Documents/Code/CleanroomProject/AppleTart/BuildControl/Bridging-Header.h -module-cache-path /Users/emaloney/Library/Developer/Xcode/DerivedData/ModuleCache -D DEBUG -serialize-debugging-options -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/swift-overrides.hmap -Xcc -iquote -Xcc /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/AppleTart-generated-files.hmap -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/AppleTart-own-target-headers.hmap -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/AppleTart-all-non-framework-target-headers.hmap -Xcc -ivfsoverlay -Xcc /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/all-product-headers.yaml -Xcc -iquote -Xcc /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/AppleTart-project-headers.hmap -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Products/Debug-iphonesimulator/include -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Products/Debug-iphonesimulator/CardIO.framework/Headers -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/DerivedSources/x86_64 -Xcc -I/Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/DerivedSources -Xcc -DDEBUG=1 -Xcc -working-directory/Users/emaloney/Documents/Code/CleanroomProject/AppleTart -emit-module-doc-path /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/Objects-normal/x86_64/Row~partial.swiftdoc -Onone -module-name AppleTart -emit-module-path /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/Objects-normal/x86_64/Row~partial.swiftmodule -serialize-diagnostics-path /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/Objects-normal/x86_64/Row.dia -emit-dependencies-path /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/Objects-normal/x86_64/Row.d -emit-reference-dependencies-path /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/Objects-normal/x86_64/Row.swiftdeps -o /Users/emaloney/Library/Developer/Xcode/DerivedData/AppleTart-gydtadecugkemlbxcybcwsxuynku/Build/Intermediates/AppleTart.build/Debug-iphonesimulator/AppleTart-iOS.build/Objects-normal/x86_64/Row.o 
> 
> 
> 
> 
>> On Oct 21, 2016, at 12:41 PM, Jon Shier <jon at jonshier.com <mailto:jon at jonshier.com>> wrote:
>> 
>> With Swift 3 I’ve found these crashes to be indicative of an underlying source issue rather than something random in the compiler. When you get the crash, can you get the backtrace in the Xcode build log? Sometimes that has clues about what it was doing when it crashed. A lot of the time when the crash is during the parsing or SIL generation for one of your functions, it will note it and you can take a look, as there may be a type mismatch. 
>> 
>> 
>> 
>> Jon
>> 
>>> On Oct 21, 2016, at 12:26 PM, Evan Maloney via swift-users <swift-users at swift.org <mailto:swift-users at swift.org>> wrote:
>>> 
>>> After a gargantuan effort updating our entire codebase to Swift 3.0, we are now being greeted with "Segmentation fault: 11" compiler crash whenever attempting to build.
>>> 
>>> The issue seems to be related to generics, and sounds similar to this issue:
>>> 
>>> 	http://stackoverflow.com/questions/39426535/segmentation-fault-11-xcode-8-swift-3-after-using-notificationcenter/39426812 <http://stackoverflow.com/questions/39426535/segmentation-fault-11-xcode-8-swift-3-after-using-notificationcenter/39426812>
>>> 
>>> I've filed a bug report that includes our project codebase, which triggers the issue 100% of the time:
>>> 
>>> 	rdar://problem/28890409
>>> 
>>> The usual work-around of turning off Whole Module Optimization (which has gotten around a lot of compiler crashes in the past) does not work here.
>>> 
>>> Unfortunately, this code is in such a tangle of generics that undoing it is not going to be simple. Until a new version of Xcode ships, we're pretty much blocked from using Swift 3.0 unless another work-around is possible.
>>> _______________________________________________
>>> swift-users mailing list
>>> swift-users at swift.org
>>> https://lists.swift.org/mailman/listinfo/swift-users
>> 
> 
> _______________________________________________
> swift-users mailing list
> swift-users at swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161021/990f58f8/attachment.html>


More information about the swift-users mailing list