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

Jon Shier jon at jonshier.com
Mon Oct 24 17:31:59 CDT 2016


	If you haven’t tried it yet, perhaps commenting out the content of the Row file will prevent the crash and let the build fail with normal errors? Then you can comment in parts of the file and see where the crash is occurring. 
	As to the overall stability of the compiler, stuff like this has always been part of being an Apple developer, but is certainly worse now in the Swift age, where it’s not just Xcode that crashes a lot.



Jon	


> On Oct 24, 2016, at 5:25 PM, Evan Maloney <emaloney at gilt.com> wrote:
> 
> I'm a bit depressed to report that our codebase still crashes the Swift compiler in the version of Xcode released today. And since we're not using ObjC generics, the issue isn't related to the radar below.
> 
> Do I have any other option other than (1) spending who knows how long attempting to rewrite our codebase of hundreds of files until the Swift compiler hopefully doesn't crash, or (2) waiting who knows how long for another version of Xcode that may still crash anyway (like this one)?
> 
> It is very frustrating that Apple is encouraging developers to adopt the latest version of Swift, and when we spend considerable time and effort updating, only to end up completely dead in the water after doing so. We're an online retailer hoping to update our app for the holiday season, and all the Swift 3 work that we've done since August is basically a waste. At this point, I don't know how we ship in time, since I am familiar enough with Apple's Xcode release cadence to assume that there will not be another Xcode release that fixes this problem before mid-November, which is when we'd need to submit our app to have it ready in time.
> 
> I should note that we've hit some variation of this problem with virtually every major Xcode beta cycle since Swift 2.0, where our code crashes the Swift compiler. I've always diligently filed radars, and the problems have gotten fixed. (Joe, you may recall that you even helped me with this exact sort of problem at WWDC this year.) But every time it happens, it's a nerve-wracking experience because I just have to wait and hope that Apple fixes it before our submission deadline. In the past, we've gotten lucky, and Apple has fixed the problem in time.
> 
> I guess we finally got unlucky this time.
> 
> I have to say, I've dealt with many different platforms and compilers over the years, from MPW to CodeWarrior, to Microsoft Visual C++, to various Java IDEs, and I've never coded on a platform where the compiler crashes so regularly. I'm beginning to wonder whether my enthusiasm about Swift is misplaced. I was never beholden to Apple's bugfix schedule when shipping Objective-C apps.
> 
> Are we just having really bad luck with the Swift compiler, or is this happening to other people as well?
> 
> 
> 
>> On Oct 21, 2016, at 5:29 PM, Joe Groff <jgroff at apple.com <mailto:jgroff at apple.com>> wrote:
>> 
>> 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 <mailto: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 <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 <mailto:swift-users at swift.org>
>>>>> https://lists.swift.org/mailman/listinfo/swift-users
>>>> 
>>> 
>>> _______________________________________________
>>> swift-users mailing list
>>> swift-users at swift.org <mailto:swift-users at swift.org>
>>> https://lists.swift.org/mailman/listinfo/swift-users <https://lists.swift.org/mailman/listinfo/swift-users>
>> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-users/attachments/20161024/5b9c3872/attachment.html>


More information about the swift-users mailing list