Xcode 9.4.1 & 10.0 beta: Segmentation fault in MergeSwiftModule in Incremental compilation mode
Originator: | rsfinn | ||
Number: | rdar://42712580 | Date Originated: | 2018-07-29 |
Status: | Open | Resolved: | |
Product: | Xcode | Product Version: | Xcode 9.4.1 (9F2000) |
Classification: | Reproducible: | Always |
The Swift compiler in Xcode 9.4.1 (9F2000) and in Xcode 10 beta 4 (10L213o) reliably crashes in the MergeSwiftModule phase when building the attached project. [The project contains both Objective-C and Swift code. The Objective-C code declares an enum type, using NS_ENUM(int, ...); the Swift code imports this type. The Swift code then declares a FixedLengthVector type (that implements Collection); the goal is that the only valid subscripts of this collection are the elements of the enum type, but note that their raw type is CInt = UInt32 and not Int, as indexes are now presumed to be (since Swift 4.1). The underlying code may no longer be the best way to achieve this, but the compiler shouldn't crash.] 0 swift 0x00000001113ddfea PrintStackTraceSignalHandler(void*) + 42 1 swift 0x00000001113dd3a6 SignalHandler(int) + 966 2 libsystem_platform.dylib 0x00007fff76703f5a _sigtramp + 26 3 libsystem_platform.dylib 0x00007ffee2237c88 _sigtramp + 1806908744 4 swift 0x000000010eb1bfea swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 778 5 swift 0x000000010eb1c72e swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 2638 6 swift 0x000000010eb1ccd2 swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 4082 7 swift 0x000000010eb1ccf6 swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 4118 8 swift 0x000000010eb19cb5 swift::ModuleFile::getDeclCheckedImpl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 51605 9 swift 0x000000010eb0d1ef swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 79 10 swift 0x000000010eb26ef4 swift::ModuleFile::loadAllMembers(swift::Decl*, unsigned long long) + 916 11 swift 0x000000010edc295f swift::IterableDeclContext::loadAllMembers() const + 207 12 swift 0x000000010ee2ad79 swift::NominalTypeDecl::lookupDirect(swift::DeclName, bool) + 1433 13 swift 0x000000010eb15cbb swift::ModuleFile::getDeclCheckedImpl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 35227 14 swift 0x000000010eb0d1ef swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 79 15 swift 0x000000010eb1bf5e swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 638 16 swift 0x000000010eb131ef swift::ModuleFile::getDeclCheckedImpl(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 24271 17 swift 0x000000010eb0d1ef swift::ModuleFile::getDeclChecked(llvm::PointerEmbeddedInt<unsigned int, 31>, llvm::Optional<swift::DeclContext*>) + 79 18 swift 0x000000010eb1bf5e swift::ModuleFile::getTypeChecked(llvm::PointerEmbeddedInt<unsigned int, 31>) + 638 19 swift 0x000000010eb28237 swift::ModuleFile::finishNormalConformance(swift::NormalProtocolConformance*, unsigned long long) + 2359 20 swift 0x000000010ee35ce6 swift::NormalProtocolConformance::getTypeWitnessAndDecl(swift::AssociatedTypeDecl*, swift::LazyResolver*, swift::SubstOptions) const + 70 21 swift 0x000000010ee3559f swift::ProtocolConformance::getTypeWitnessAndDecl(swift::AssociatedTypeDecl*, swift::LazyResolver*, swift::SubstOptions) const + 463 22 swift 0x000000010ee4a977 getMemberForBaseType(llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::Type, swift::Type, swift::AssociatedTypeDecl*, swift::Identifier, swift::SubstOptions) + 1207 23 swift 0x000000010ee4a1e8 llvm::Optional<swift::Type> llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>::callback_fn<substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::SubstOptions)::$_18>(long, swift::TypeBase*) + 1384 24 swift 0x000000010ee43389 swift::Type::transformRec(llvm::function_ref<llvm::Optional<swift::Type> (swift::TypeBase*)>) const + 137 25 swift 0x000000010ee493b3 substType(swift::Type, llvm::function_ref<swift::Type (swift::SubstitutableType*)>, llvm::function_ref<llvm::Optional<swift::ProtocolConformanceRef> (swift::CanType, swift::Type, swift::ProtocolType*)>, swift::SubstOptions) + 211 26 swift 0x000000010e854b09 (anonymous namespace)::SILTypeSubstituter::visitType(swift::CanType) + 89 27 swift 0x000000010e854eb2 (anonymous namespace)::SILTypeSubstituter::substSILFunctionType(swift::CanTypeWrapper<swift::SILFunctionType>) + 754 28 swift 0x000000010e8553b3 swift::SILFunctionType::substGenericArgs(swift::SILModule&, llvm::ArrayRef<swift::Substitution>) + 275 29 swift 0x000000010dc3fb58 swift::SILBuilder::createApply(swift::SILLocation, swift::SILValue, llvm::ArrayRef<swift::Substitution>, llvm::ArrayRef<swift::SILValue>, bool, swift::GenericSpecializationInformation const*) + 184 30 swift 0x000000010eb3cccf swift::SILDeserializer::readSILInstruction(swift::SILFunction*, swift::SILBasicBlock*, swift::SILBuilder&, unsigned int, llvm::SmallVectorImpl<unsigned long long>&) + 53327 31 swift 0x000000010eb2f450 swift::SILDeserializer::readSILFunction(llvm::PointerEmbeddedInt<unsigned int, 31>, swift::SILFunction*, llvm::StringRef, bool, bool) + 5712 32 swift 0x000000010eb423cd swift::SILDeserializer::getAllSILFunctions() + 893 33 swift 0x000000010ebdac54 swift::SerializedSILLoader::getAllForModule(swift::Identifier, swift::FileUnit*) + 196 34 swift 0x000000010da3c48b performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 30459 35 swift 0x000000010da33304 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7908 36 swift 0x000000010d9e7ce5 main + 18917 37 libdyld.dylib 0x00007fff763f5015 start + 1 38 libdyld.dylib 0x0000000000000047 start + 2311106611 Stack dump: 1. While reading from 'VectorEngine' 2. While finishing conformance for type 'Partnership' 3. While ... to 'Strideable' in module 'Swift' 4. While deserializing 'Stride' (TypeAliasDecl #20) in 'VectorEngine' 5. While deserializing decl #34 (XREF) in 'VectorEngine' 6. Cross-reference to module 'VectorEngine' ... Partnership ... RawValue 7. While loading members for extension of Partnership in module 'VectorEngine' 8. While deserializing 'advanced' (FuncDecl #29) in 'VectorEngine'
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Still crashes in Xcode 10 GM seed
The problem still occurs in the Xcode 10 GM seed (10A254a).
Still crashes in Xcode 10.0b6; work around by using Whole Module compilation mode
The problem is still present in Xcode 10.0 beta 6 (10L232m). However, I discovered that if I change the "Compilation Mode" setting (under "Swift Compiler - Code Generation") from "Incremental" (the default for Debug configuration) to "Whole Module", the crash is avoided and the build completes, although it takes much longer to do so.