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-11117] Compiler Crash when using generic parameter in typealias tuple to fulfill associated type requirement #53513

Closed
ffried opened this issue Jul 12, 2019 · 5 comments
Assignees
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

Comments

@ffried
Copy link
Contributor

ffried commented Jul 12, 2019

Previous ID SR-11117
Radar rdar://problem/53010355
Original Reporter @ffried
Type Bug
Status Resolved
Resolution Duplicate

Attachment: Download

Environment

Apple Swift version 5.1 (swiftlang-1100.0.212.5 clang-1100.0.28.2)
Target: x86_64-apple-darwin19.0.0

(The Swift version bundled in Xcode 11 beta 3)

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee @ffried
Priority Medium

md5: d6731d3fd3a0ab07f293e0ae0249df46

duplicates:

  • SR-10728 Conditional Conformance Compiler Crash

Issue Description:

The following code causes a compiler crash:

protocol Base {
   associatedtype Parameters
   init(params: Parameters)
}

struct ABC<Object>: Base {
   typealias Parameters = (Int, (Object) -> ())
   init(params: Parameters) {}
}

Backtrace when running swift s51_associatedInitCrash.swift:

Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -interpret s51_associatedInitCrash.swift -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -color-diagnostics -module-name s51_associatedInitCrash 
1.  While type-checking protocol conformance to 'Base' (at s51_associatedInitCrash.swift:1:1) for type 'ABC<Object>' (declared at [s51_associatedInitCrash.swift:6:1 - line:9:1] RangeText="struct ABC<Object>: Base {
   typealias Parameters = (Int, (Object) -> ())
   init(params: Parameters) {}
")
0  swift                    0x000000010bcb8c83 PrintStackTraceSignalHandler(void*) + 51
1  swift                    0x000000010bcb8456 SignalHandler(int) + 358
2  libsystem_platform.dylib 0x00007fff6d981b1d _sigtramp + 29
3  libsystem_platform.dylib 0x00007ffee8388e10 _sigtramp + 2057335568
4  swift                    0x0000000108437e8a swift::constraints::ConstraintLocatorBuilder::trySimplifyToExpr() const + 122
5  swift                    0x0000000108332e41 swift::constraints::ConstraintSystem::matchFunctionTypes(swift::FunctionType*, swift::FunctionType*, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 1489
6  swift                    0x000000010831ae84 swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 4484
7  swift                    0x000000010831b257 swift::constraints::ConstraintSystem::matchTypes(swift::Type, swift::Type, swift::constraints::ConstraintKind, swift::OptionSet<swift::constraints::ConstraintSystem::TypeMatchFlags, unsigned int>, swift::constraints::ConstraintLocatorBuilder) + 5463
8  swift                    0x00000001083197dd swift::constraints::ConstraintSystem::addConstraint(swift::constraints::ConstraintKind, swift::Type, swift::Type, swift::constraints::ConstraintLocatorBuilder, bool) + 125
9  swift                    0x00000001084a89b3 llvm::Optional<swift::RequirementMatch> llvm::function_ref<llvm::Optional<swift::RequirementMatch> (swift::Type, swift::Type)>::callback_fn<swift::matchWitness(swift::TypeChecker&, llvm::DenseMap<std::__1::pair<swift::GenericSignature const*, swift::ClassDecl const*>, swift::RequirementEnvironment, llvm::DenseMapInfo<std::__1::pair<swift::GenericSignature const*, swift::ClassDecl const*> >, llvm::detail::DenseMapPair<std::__1::pair<swift::GenericSignature const*, swift::ClassDecl const*>, swift::RequirementEnvironment> >&, swift::ProtocolDecl*, swift::ProtocolConformance*, swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*)::$_1>(long, swift::Type, swift::Type) + 83
10 swift                    0x00000001084a77b6 swift::matchWitness(swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*, llvm::function_ref<std::__1::tuple<llvm::Optional<swift::RequirementMatch>, swift::Type, swift::Type> ()>, llvm::function_ref<llvm::Optional<swift::RequirementMatch> (swift::Type, swift::Type)>, llvm::function_ref<swift::RequirementMatch (bool, llvm::ArrayRef<swift::OptionalAdjustment>)>) + 5462
11 swift                    0x00000001084a867e swift::matchWitness(swift::TypeChecker&, llvm::DenseMap<std::__1::pair<swift::GenericSignature const*, swift::ClassDecl const*>, swift::RequirementEnvironment, llvm::DenseMapInfo<std::__1::pair<swift::GenericSignature const*, swift::ClassDecl const*> >, llvm::detail::DenseMapPair<std::__1::pair<swift::GenericSignature const*, swift::ClassDecl const*>, swift::RequirementEnvironment> >&, swift::ProtocolDecl*, swift::ProtocolConformance*, swift::DeclContext*, swift::ValueDecl*, swift::ValueDecl*) + 1166
12 swift                    0x00000001084aace5 swift::WitnessChecker::findBestWitness(swift::ValueDecl*, bool*, swift::NormalProtocolConformance*, llvm::SmallVectorImpl<swift::RequirementMatch>&, unsigned int&, unsigned int&, bool&) + 1573
13 swift                    0x00000001084b515d swift::ConformanceChecker::resolveWitnessViaLookup(swift::ValueDecl*) + 653
14 swift                    0x00000001084b0256 swift::MultiConformanceChecker::checkIndividualConformance(swift::NormalProtocolConformance*, bool) + 11958
15 swift                    0x00000001084acef2 swift::MultiConformanceChecker::checkAllConformances() + 130
16 swift                    0x00000001084c53ee swift::TypeChecker::checkConformancesInContext(swift::DeclContext*, swift::IterableDeclContext*) + 7214
17 swift                    0x0000000108514ab5 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int) + 1957
18 swift                    0x0000000107c0c1ca swift::CompilerInstance::performSemaUpTo(swift::SourceFile::ASTStage_t) + 4746
19 swift                    0x000000010790403a performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&, swift::FrontendObserver*, swift::UnifiedStatsReporter*) + 794
20 swift                    0x0000000107900474 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 6868
21 swift                    0x000000010788efb3 main + 1219
22 libdyld.dylib            0x00007fff6d780c49 start + 1
fish: 'swift s51_associatedInitCrash.s…' terminated by signal SIGSEGV (Address boundary error)

Note:
Parameters has to be used in the initializer it has to be defined as a Tuple of at least two elements with one being a closure which uses the generic parameter either as parameter or as return type.

@ffried
Copy link
Contributor Author

ffried commented Jul 12, 2019

This might be related to SR-11117, but I'm not sure (which is why I created a new issue)

@belkadan
Copy link
Contributor

Copy/paste error? (That's this issue.)

@swift-ci create

@ffried
Copy link
Contributor Author

ffried commented Jul 12, 2019

@belkadan: Argh, totally. I meant SR-11074, sorry.

@belkadan
Copy link
Contributor

Looks like that one turned out to be a dup of SR-10728, so maybe this is fixed in master. cc @xedin

@xedin
Copy link
Member

xedin commented Jul 12, 2019

This is indeed a duplicate of SR-10728. The fix has been merged to master and 5.1 yesterday, so you should be able to verify using the next nightly.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
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
Projects
None yet
Development

No branches or pull requests

4 participants