Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-15792] error: Segmentation fault: 11 on compile of project #58069

Closed
swift-ci opened this issue Jan 31, 2022 · 13 comments
Closed

[SR-15792] error: Segmentation fault: 11 on compile of project #58069

swift-ci opened this issue Jan 31, 2022 · 13 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software generics Feature: generic declarations and types swift 5.6 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Jan 31, 2022

Previous ID SR-15792
Radar rdar://problem/88474300
Original Reporter lmaguire (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

macOS Monterey 12.2 (21D49)

Xcode Version 13.3 beta (13E5086k)

MacBook Pro (16-inch, 2019)

2.6 GHz 6-Core Intel Core i7

Additional Detail from JIRA
Votes 1
Component/s swift
Labels Bug
Assignee None
Priority Medium

md5: 2f8ceba9b8ca620b92d0114165082661

is duplicated by:

  • SR-15777 Swift 5.6.0.320.8 crashes in protocol conformance checking
  • SR-15962 Crash when compiling RealmSwift v10.22.0

Issue Description:

Since upgrading to Xcode Version 13.3 beta (13E5086k) we are seeing issues where compiling our project generates a "error: Segmentation fault: 11" / "error: Abort trap: 6". The project in question compiles with no issues on Xcode Version 13.2.1 (13C100).

Reproduction:

Crash 1:

0. Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Aliases.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/AnyRealmValue.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/App.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/BSON.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Combine.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/CustomPersistable.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Decimal128.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/EmbeddedObject.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Error.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/BasicTypes.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/CollectionAccess.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/ComplexTypes.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/KeyPathStrings.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/ObjcBridgeable.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/Persistable.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/PropertyAccessors.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/RealmCollectionImpl.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/SchemaDiscovery.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/LinkingObjects.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/List.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Map.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Migration.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/MongoClient.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/MutableSet.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Object.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ObjectId.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ObjectSchema.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ObjectiveCSupport+AnyRealmValue.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ObjectiveCSupport+BSON.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ObjectiveCSupport+Sync.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ObjectiveCSupport.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Optional.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/PersistedProperty.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Projection.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Property.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Query.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Realm.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/RealmCollection.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/RealmConfiguration.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/RealmKeyedCollection.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/RealmProperty.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Results.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Schema.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/SortDescriptor.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/SwiftUI.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Sync.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ThreadSafeReference.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Util.swift -target x86_64-apple-macos10.10 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -I /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Products/Debug -I /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Products/Debug/PackageFrameworks -F /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Products/Debug/PackageFrameworks -F /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Products/Debug/PackageFrameworks -F /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Products/Debug -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/lee.maguire/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D DEBUG -D Xcode -new-driver-path /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -serialize-debugging-options -Xcc -working-directory -Xcc /Users/lee.maguire/Projects/realm-cocoa -resource-dir /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/GeneratedModuleMaps/Bid.modulemap -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/swift-overrides.hmap -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/SourcePackages/checkouts/realm-core/src/external/IntelRDFPMathLib20U2/LIBRARY/src -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/SourcePackages/checkouts/realm-core/src -Xcc -I/Users/lee.maguire/Projects/realm-cocoa/include -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Products/Debug/include -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/DerivedSources-normal/x86_64 -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/DerivedSources/x86_64 -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/DerivedSources -Xcc -DSWIFT_PACKAGE -Xcc -DDEBUG=1 -module-name RealmSwift -target-sdk-version 12.3 -emit-module-doc-path /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/RealmSwift.swiftdoc -emit-module-source-info-path /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/RealmSwift.swiftsourceinfo -emit-objc-header-path /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/RealmSwift-Swift.h -o /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/RealmSwift.swiftmodule -emit-abi-descriptor-path /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/RealmSwift.abi.json

1. Apple Swift version 5.6 (swiftlang-5.6.0.320.8 clang-1316.0.18.8)
2. Compiling with the current language version
3. While evaluating request TypeCheckSourceFileRequest(source_file "/Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/ObjcBridgeable.swift")
4. While type-checking extension of RealmCollectionImpl (at /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/ObjcBridgeable.swift:174:1)
5. While type-checking declaration 0x7fdadb157600 (at /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/ObjcBridgeable.swift:175:12)
6. While evaluating request IsGetterMutatingRequest(RealmSwift.(file).RealmCollectionImpl extension._rlmObjcValue@/Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/ObjcBridgeable.swift:175:16)
7. While building rewrite system for generic signature <τ_0_0 where τ_0_0 : RealmCollectionImpl>
8. While evaluating request ProtocolDependenciesRequest(RealmSwift.(file).RealmCollectionImpl@/Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/RealmCollectionImpl.swift:30:19)
9. While evaluating request RequirementSignatureRequest(RealmSwift.(file).RealmCollectionImpl@/Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/RealmCollectionImpl.swift:30:19)

Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x000000010c8f89e7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x000000010c8f7a38 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000010c8f9040 SignalHandler(int) + 288
3  libsystem_platform.dylib 0x00007ff809584e2d _sigtramp + 29
4  libsystem_platform.dylib 0x00007fdae9010500 _sigtramp + 18446743948612908784
5  swift-frontend           0x0000000108a8c66b swift::RequirementSignatureRequest::evaluate(swift::Evaluator&, swift::ProtocolDecl\*) const::$_71::operator()() const + 539
6  swift-frontend           0x0000000108a8be8b swift::RequirementSignatureRequest::evaluate(swift::Evaluator&, swift::ProtocolDecl\*) const + 155
7  swift-frontend           0x000000010898e89a swift::RequirementSignatureRequest::OutputType swift::evaluateOrDefault<swift::RequirementSignatureRequest>(swift::Evaluator&, swift::RequirementSignatureRequest, swift::RequirementSignatureRequest::OutputType) + 1082
8  swift-frontend           0x0000000108b38918 swift::ProtocolDependenciesRequest::evaluate(swift::Evaluator&, swift::ProtocolDecl\*) const + 456
9  swift-frontend           0x000000010898d76a swift::ProtocolDependenciesRequest::OutputType swift::evaluateOrDefault<swift::ProtocolDependenciesRequest>(swift::Evaluator&, swift::ProtocolDependenciesRequest, swift::ProtocolDependenciesRequest::OutputType) + 1322
10 swift-frontend           0x0000000108b38f94 swift::rewriting::RuleBuilder::collectRulesFromReferencedProtocols() + 196
11 swift-frontend           0x0000000108b38c82 swift::rewriting::RuleBuilder::addRequirements(llvm::ArrayRef<swift::Requirement>) + 146
12 swift-frontend           0x0000000108b3d5bc swift::rewriting::RequirementMachine::initWithGenericSignature(swift::CanGenericSignature) + 1068
13 swift-frontend           0x0000000108b450d4 swift::rewriting::RewriteContext::getRequirementMachine(swift::CanGenericSignature) + 308
14 swift-frontend           0x0000000108a597dc swift::GenericSignatureImpl::requiresClass(swift::Type) const + 604
15 swift-frontend           0x0000000108a22da3 swift::DeclContext::hasValueSemantics() const + 211
16 swift-frontend           0x00000001086d3369 swift::IsGetterMutatingRequest::evaluate(swift::Evaluator&, swift::AbstractStorageDecl\*) const + 249
17 swift-frontend           0x00000001089b0199 llvm::Expected<swift::IsGetterMutatingRequest::OutputType> swift::Evaluator::getResultCached<swift::IsGetterMutatingRequest, (void\*)0>(swift::IsGetterMutatingRequest const&) + 1145
18 swift-frontend           0x0000000108976822 swift::IsGetterMutatingRequest::OutputType swift::evaluateOrDefault<swift::IsGetterMutatingRequest>(swift::Evaluator&, swift::IsGetterMutatingRequest, swift::IsGetterMutatingRequest::OutputType) + 34
19 swift-frontend           0x000000010864cc51 (anonymous namespace)::DeclChecker::visitBoundVariable(swift::VarDecl\*) + 209
20 swift-frontend           0x000000010864c165 void llvm::function_ref<void (swift::VarDecl\*)>::callback_fn<(anonymous namespace)::DeclChecker::visitPatternBindingDecl(swift::PatternBindingDecl\*)::'lambda'(swift::VarDecl\*)>(long, swift::VarDecl\*) + 37
21 swift-frontend           0x0000000108640b00 swift::ASTVisitor<(anonymous namespace)::DeclChecker, void, void, void, void, void, void>::visit(swift::Decl\*) + 6448
22 swift-frontend           0x000000010863bda9 (anonymous namespace)::DeclChecker::visit(swift::Decl\*) + 441
23 swift-frontend           0x0000000108643edb swift::ASTVisitor<(anonymous namespace)::DeclChecker, void, void, void, void, void, void>::visit(swift::Decl\*) + 19723
24 swift-frontend           0x000000010863bda9 (anonymous namespace)::DeclChecker::visit(swift::Decl\*) + 441
25 swift-frontend           0x000000010863bbe1 swift::TypeChecker::typeCheckDecl(swift::Decl\*, bool) + 193
26 swift-frontend           0x000000010870a837 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile\*) const + 567
27 swift-frontend           0x000000010870d999 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 633
28 swift-frontend           0x000000010870a5b2 swift::performTypeChecking(swift::SourceFile&) + 114
29 swift-frontend           0x00000001077de02d swift::CompilerInstance::performSema() + 285
30 swift-frontend           0x000000010763c9ca swift::performFrontend(llvm::ArrayRef<char const\*>, char const\*, void\*, swift::FrontendObserver\*) + 14234
31 swift-frontend           0x00000001075fc178 swift::mainEntry(int, char const\*\*) + 1064
32 dyld                     0x000000011bcde4fe start + 462
error: Segmentation fault: 11 (in target 'RealmSwift' from project 'Realm')

Crash 2:

0. Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Aliases.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/AnyRealmValue.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/App.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/BSON.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Combine.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/CustomPersistable.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Decimal128.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/EmbeddedObject.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Error.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/BasicTypes.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/CollectionAccess.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/ComplexTypes.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/KeyPathStrings.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/ObjcBridgeable.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/Persistable.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/PropertyAccessors.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/RealmCollectionImpl.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Impl/SchemaDiscovery.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/LinkingObjects.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/List.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Map.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Migration.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/MongoClient.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/MutableSet.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Object.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ObjectId.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ObjectSchema.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ObjectiveCSupport+AnyRealmValue.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ObjectiveCSupport+BSON.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ObjectiveCSupport+Sync.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ObjectiveCSupport.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Optional.swift -primary-file /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/PersistedProperty.swift -primary-file /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Projection.swift -primary-file /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Property.swift -primary-file /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Query.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Realm.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/RealmCollection.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/RealmConfiguration.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/RealmKeyedCollection.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/RealmProperty.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Results.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Schema.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/SortDescriptor.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/SwiftUI.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Sync.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/ThreadSafeReference.swift /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Util.swift -supplementary-output-file-map /var/folders/r6/ltscw4md2nv5mrvl_233q4cc0000gp/T/TemporaryDirectory.ia0x6m/supplementaryOutputs-9 -target x86_64-apple-macos10.10 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -I /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Products/Debug -I /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Products/Debug/PackageFrameworks -F /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Products/Debug/PackageFrameworks -F /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Products/Debug/PackageFrameworks -F /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Products/Debug -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -enable-testing -g -module-cache-path /Users/lee.maguire/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D DEBUG -D Xcode -new-driver-path /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -serialize-debugging-options -Xcc -working-directory -Xcc /Users/lee.maguire/Projects/realm-cocoa -resource-dir /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -fmodule-map-file=/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/GeneratedModuleMaps/Bid.modulemap -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/swift-overrides.hmap -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/SourcePackages/checkouts/realm-core/src/external/IntelRDFPMathLib20U2/LIBRARY/src -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/SourcePackages/checkouts/realm-core/src -Xcc -I/Users/lee.maguire/Projects/realm-cocoa/include -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Products/Debug/include -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/DerivedSources-normal/x86_64 -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/DerivedSources/x86_64 -Xcc -I/Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/DerivedSources -Xcc -DSWIFT_PACKAGE -Xcc -DDEBUG=1 -module-name RealmSwift -target-sdk-version 12.3 -o /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/PersistedProperty.o -o /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/Projection.o -o /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/Property.o -o /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Build/Intermediates.noindex/Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/Query.o -index-unit-output-path /Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/PersistedProperty.o -index-unit-output-path /Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/Projection.o -index-unit-output-path /Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/Property.o -index-unit-output-path /Realm.build/Debug/RealmSwift.build/Objects-normal/x86_64/Query.o -index-store-path /Users/lee.maguire/Library/Developer/Xcode/DerivedData/realm-cocoa-gcwonhftuxisutgjxkfbtblzzhsy/Index/DataStore -index-system-modules

1. Apple Swift version 5.6 (swiftlang-5.6.0.320.8 clang-1316.0.18.8)
2. Compiling with the current language version
3. While evaluating request TypeCheckSourceFileRequest(source_file "/Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Query.swift")
4. While type-checking extension of Query (at /Users/lee.maguire/Projects/realm-cocoa/RealmSwift/Query.swift:523:1)
5. While evaluating request RequirementRequest(extension of Query, 1, interface)
6. While evaluating request ResolveTypeRequest(while resolving type , T.Element, (null))
7. While building rewrite system for generic signature <τ_0_0 where τ_0_0 : RealmCollection, τ_0_0.Element : PersistableEnum, τ_0_0.Element.RawValue : RealmCollectionValue>

Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x000000010ab969e7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 39
1  swift-frontend           0x000000010ab95a38 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000010ab97040 SignalHandler(int) + 288
3  libsystem_platform.dylib 0x00007ff809584e2d _sigtramp + 29
4  libsystem_platform.dylib 0x0000000000100424 _sigtramp + 18446603370425202196
5  libsystem_c.dylib        0x00007ff8094bbd10 abort + 123
6  swift-frontend           0x0000000106ddc57e swift::rewriting::RequirementMachine::computeCompletion(swift::rewriting::RewriteSystem::ValidityPolicy)::$_0::operator()() const + 142
7  swift-frontend           0x0000000106ddb77f swift::rewriting::RequirementMachine::computeCompletion(swift::rewriting::RewriteSystem::ValidityPolicy) + 223
8  swift-frontend           0x0000000106ddb5e2 swift::rewriting::RequirementMachine::initWithGenericSignature(swift::CanGenericSignature) + 1106
9  swift-frontend           0x0000000106de30d4 swift::rewriting::RewriteContext::getRequirementMachine(swift::CanGenericSignature) + 308
10 swift-frontend           0x0000000106cfc204 swift::GenericSignatureImpl::lookupNestedType(swift::Type, swift::Identifier) const + 612
11 swift-frontend           0x000000010699a1ed (anonymous namespace)::TypeResolver::resolveIdentifierType(swift::IdentTypeRepr\*, swift::TypeResolutionOptions) + 2173
12 swift-frontend           0x0000000106996ff1 swift::ResolveTypeRequest::evaluate(swift::Evaluator&, swift::TypeResolution const\*, swift::TypeRepr\*, swift::GenericParamList\*) const + 97
13 swift-frontend           0x00000001069a6ec9 llvm::Expected<swift::ResolveTypeRequest::OutputType> swift::Evaluator::getResultUncached<swift::ResolveTypeRequest>(swift::ResolveTypeRequest const&) + 505
14 swift-frontend           0x0000000106996f19 swift::TypeResolution::resolveType(swift::TypeRepr\*, swift::GenericParamList\*) const + 89
15 swift-frontend           0x0000000106908f7d swift::RequirementRequest::evaluate(swift::Evaluator&, swift::WhereClauseOwner, unsigned int, swift::TypeResolutionStage) const + 525
16 swift-frontend           0x0000000106e1f7d9 llvm::Expected<swift::RequirementRequest::OutputType> swift::Evaluator::getResultUncached<swift::RequirementRequest>(swift::RequirementRequest const&) + 1225
17 swift-frontend           0x0000000106e1d0e9 swift::WhereClauseOwner::visitRequirements(swift::TypeResolutionStage, llvm::function_ref<bool (swift::Requirement, swift::RequirementRepr\*)>) const && + 1097
18 swift-frontend           0x00000001068e6dfe checkGenericParams(swift::GenericContext\*) + 318
19 swift-frontend           0x00000001068e1ea4 swift::ASTVisitor<(anonymous namespace)::DeclChecker, void, void, void, void, void, void>::visit(swift::Decl\*) + 19668
20 swift-frontend           0x00000001068d9da9 (anonymous namespace)::DeclChecker::visit(swift::Decl\*) + 441
21 swift-frontend           0x00000001068d9be1 swift::TypeChecker::typeCheckDecl(swift::Decl\*, bool) + 193
22 swift-frontend           0x00000001069a8837 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile\*) const + 567
23 swift-frontend           0x00000001069ab999 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) + 633
24 swift-frontend           0x00000001069a85b2 swift::performTypeChecking(swift::SourceFile&) + 114
25 swift-frontend           0x0000000105a7bfe9 swift::CompilerInstance::performSema() + 217
26 swift-frontend           0x00000001058da9ca swift::performFrontend(llvm::ArrayRef<char const\*>, char const\*, void\*, swift::FrontendObserver\*) + 14234
27 swift-frontend           0x000000010589a178 swift::mainEntry(int, char const\*\*) + 1064
28 dyld                     0x000000010dd674fe start + 462
error: Abort trap: 6 (in target 'RealmSwift' from project 'Realm')
@gregomni
Copy link
Collaborator

gregomni commented Feb 2, 2022

I don't think I can share the code – working on trying to make something minimized – but it looks like I'm running into the same (or nearby) issue with Xcode 13.3 beta (13E5086k).

3  libsystem_platform.dylib 0x000000019afe04e4 _sigtramp + 56
4  swift-frontend           0x0000000105896898 swift::rewriting::PropertyMap::concretizeNestedTypesFromConcreteParent(swift::rewriting::Term, swift::RequirementKind, swift::CanType, llvm::ArrayRef<swift::rewriting::Term>, llvm::ArrayRef<swift::ProtocolDecl const*>, llvm::TinyPtrVector<swift::ProtocolConformance*>&, llvm::SmallVectorImpl<std::__1::pair<swift::rewriting::MutableTerm, swift::rewriting::MutableTerm> >&) const + 1472
5  swift-frontend           0x0000000105896898 swift::rewriting::PropertyMap::concretizeNestedTypesFromConcreteParent(swift::rewriting::Term, swift::RequirementKind, swift::CanType, llvm::ArrayRef<swift::rewriting::Term>, llvm::ArrayRef<swift::ProtocolDecl const*>, llvm::TinyPtrVector<swift::ProtocolConformance*>&, llvm::SmallVectorImpl<std::__1::pair<swift::rewriting::MutableTerm, swift::rewriting::MutableTerm> >&) const + 1472
6  swift-frontend           0x0000000105896224 swift::rewriting::PropertyMap::concretizeNestedTypesFromConcreteParents(llvm::SmallVectorImpl<std::__1::pair<swift::rewriting::MutableTerm, swift::rewriting::MutableTerm> >&) const + 532
7  swift-frontend           0x0000000105894ba8 swift::rewriting::PropertyMap::buildPropertyMap(unsigned int, unsigned int) + 2652
8  swift-frontend           0x00000001058a3178 swift::rewriting::RequirementMachine::computeCompletion(swift::rewriting::RewriteSystem::ValidityPolicy) + 192
9  swift-frontend           0x00000001058a2fe0 swift::rewriting::RequirementMachine::initWithGenericSignature(swift::CanGenericSignature) + 892
10 swift-frontend           0x00000001058aa034 swift::rewriting::RewriteContext::getRequirementMachine(swift::CanGenericSignature) + 240

@slavapestov
Copy link
Member

@swift-ci create

@slavapestov
Copy link
Member

slavapestov commented Feb 4, 2022

Reduced:

protocol Collection {
  associatedtype SubSequence: Collection
}

protocol BidirectionalCollection: Collection where SubSequence: BidirectionalCollection {}

struct Slice<Base : Collection> : Collection {
  typealias SubSequence = Slice<Base>
}

extension Slice: BidirectionalCollection where Base : BidirectionalCollection {}

protocol SlicedCollection: BidirectionalCollection where SubSequence == Slice<Self> {}

@slavapestov
Copy link
Member

slavapestov commented Feb 4, 2022

Reduced the other problem:

public protocol RealmCollection: RealmCollectionBase {}

public protocol RealmCollectionBase: RandomAccessCollection where Element: RealmCollectionValue {
}

public protocol RealmCollectionValue: _HasPersistedType where PersistedType: RealmCollectionValue {}

public protocol _HasPersistedType {
  associatedtype PersistedType
}

public protocol PersistableEnum: _PersistableInsideOptional, _RealmCollectionValueInsideOptional {
}

public protocol _PersistableInsideOptional: _Persistable where PersistedType: _PersistableInsideOptional {}

public protocol _Persistable: _HasPersistedType where PersistedType: _Persistable {}

public protocol _RealmCollectionValueInsideOptional: RealmCollectionValue where PersistedType: _RealmCollectionValueInsideOptional {}

func foo<T>(_: T) where T : RealmCollection, T.Element : PersistableEnum {
  _ = T.self
}

@slavapestov
Copy link
Member

@gregomni Can you file a separate bug for your crash since I don't think it's related to either of these two above?

@slavapestov
Copy link
Member

slavapestov commented Feb 7, 2022

Fix for the first problem: #41255

The second problem appears because the recursion on the PersistedType associated type is too complex. On the main branch, this no longer triggers an internal assertion and instead emits a diagnostic on the PersistentEnum protocol.

The core of the problem is that while we can support infinitely-recursive associated types with requirements, or merging two associated types with the same name from unrelated protocols, we cannot do both.

Here is the simplest example showing the unsupported case – this example actually works in 5.6 but it's banned entirely on the main branch because we can't actually support it correctly with the current design:

protocol P0 {
  associatedtype PersistedType : P0
}

protocol P1 : P0 where PersistedType : P1 {}

protocol P2 : P0 where PersistedType : P2 {}

protocol P3 {
  associatedtype X : P1 & P2
}

Your project is the first one I've seen with a non-contrived example of this issue – congratulations 🙂

There are two solutions right now:

  • Set the OTHER_SWIFT_FLAGS on all targets to include "-Xfrontend -requirement-machine=off". I don't recommend doing this since all downstream dependencies that use your framework will also have to set the flag, and the flag will be removed in a future release of the compiler.
  • Change the protocol hierarchy. For example, I was able to get the project to build by adding a requirement to the where clause of the _Persistable protocol:

    public protocol _Persistable: _HasPersistedType where PersistedType: _Persistable, PersistedType. PersistedType == PersistedType {}

    Of course, I don't know if it is semantically valid to say that projecting the PersistedType reaches a fixed point after two steps.

  • If you require an infinitely recursive associated type here, you could instead try to redesign the PersistedEnum protocol so that it does not merge the PersistedType associated type of two unrelated protocols together.

Please reach out if you need further help here, and I apologize for the source breaking change.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Feb 8, 2022

Comment by Thomas Goyne (JIRA)

Requiring a fixed point after two steps is probably fine. That's actually the intended design, and IIRC the problem with expressing that in the protocol was just that one of the older versions of Swift we support didn't like it. It's technically an API breaking change to add now, but it's very unlikely that anyone is intentionally depending on multiple steps and we're generally okay with shipping theoretically breaking changes tied directly to new Swift versions.

@slavapestov
Copy link
Member

Thank you for the response. I actually tried the change I suggested with Swift 5.5 and it seemed to work. Let me know if you run into any trouble.

@slavapestov
Copy link
Member

Do you mind if I resolve the bug since the fix for the first crasher has been merged into the release/5.6 branch?

@swift-ci
Copy link
Collaborator Author

Comment by Thomas Goyne (JIRA)

With Xcode 13.3 beta 3 the compiler still crashes rather than failing gracefully without the `PersistedType.PersistedType == PersistedType` requirement. `PersistedType.PersistedType == PersistedType` also doesn't actually work; the library builds but the tests don't. `PersistedType.PersistedType.PersistedType == PersistedType.PersistedType` appears to be the correct requirement.

@slavapestov
Copy link
Member

The compiler fails gracefully on the main branch once the `-requirement-machine-protocol-signatures=on` flag is enabled by default. I'll resolve this bug once that's in place.

@nevil
Copy link

nevil commented Mar 11, 2022

This is perhaps the same issue but the call stack is different...
https://bugs.swift.org/browse/SR-15962

@slavapestov
Copy link
Member

-requirement-machine-protocol-signatures=on is enabled in the 5.7 branch which means we will diagnose the unsolvable protocol rewrite system instead of crashing.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis compiler crash generics Feature: generic declarations and types crash Bug: A crash, i.e., an abnormal termination of software swift 5.6 and removed swift labels Jan 16, 2023
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself crash Bug: A crash, i.e., an abnormal termination of software generics Feature: generic declarations and types swift 5.6 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

5 participants