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

Compiler crash with associatedtype inferred from some return type + generic constraints #66840

Open
KeithBauerANZ opened this issue Jun 22, 2023 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@KeithBauerANZ
Copy link

Description

Simplified from an example that came up in SwiftUI, this crashes the compiler:

protocol Q {}

class C {}
class D<T: Q>: C {}

protocol P {
    associatedtype A: C
    func requirement1() -> A
    func requirement2(_: A)
}

struct S<T: Q>: P {
    func requirement1() -> some C { D<T>() }
    func requirement2(_ a: A) {}
}
swiftc CrashInferringAssociatedType.swift
error: compile command failed due to signal 11 (use -v to see invocation)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/<me>/Applications/Xcode-15.0.0-Beta.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file CrashInferringAssociatedType.swift -target arm64-apple-macosx13.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Users/<me>/Applications/Xcode-15.0.0-Beta.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -color-diagnostics -new-driver-path /Users/<me>/Applications/Xcode-15.0.0-Beta.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -plugin-path /Users/<me>/Applications/Xcode-15.0.0-Beta.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/<me>/Applications/Xcode-15.0.0-Beta.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -resource-dir /Users/<me>/Applications/Xcode-15.0.0-Beta.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -module-name CrashInferringAssociatedType -disable-clang-spi -target-sdk-version 14.0 -target-sdk-name macosx14.0 -o /var/folders/jg/3hxr5hxx7hd3kcfjs1c7ylqr0000gp/T/TemporaryDirectory.d28LZd/CrashInferringAssociatedType-1.o
1.	Apple Swift version 5.9 (swiftlang-5.9.0.114.10 clang-1500.0.29.1)
2.	Compiling with the current language version
3.	While evaluating request IRGenRequest(IR Generation for file "CrashInferringAssociatedType.swift")
4.	While emitting IR SIL function "@$s28CrashInferringAssociatedType1SVyxGAA1PA2aEP12requirement2yy1AQzFTW".
 for 'requirement2(_:)' (at CrashInferringAssociatedType.swift:14:5)
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           0x0000000109c8004c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000109c7f210 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000109c8064c SignalHandler(int) + 352
3  libsystem_platform.dylib 0x000000018cbbea24 _sigtramp + 56
4  swift-frontend           0x0000000104a54038 swift::irgen::CallEmission::emitCallSite() + 52
5  swift-frontend           0x0000000104a56374 swift::irgen::CallEmission::emitToExplosion(swift::irgen::Explosion&, bool) + 2380
6  swift-frontend           0x0000000104c96858 (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 4072
7  swift-frontend           0x0000000104c6d110 (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 2676
8  swift-frontend           0x0000000104c6ab4c swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 11112
9  swift-frontend           0x0000000104ac578c swift::irgen::IRGenerator::emitLazyDefinitions() + 4728
10 swift-frontend           0x0000000104c1a6c0 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 5852
11 swift-frontend           0x0000000104c67d58 swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 176
12 swift-frontend           0x0000000104c2bfe0 llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 1516
13 swift-frontend           0x0000000104c1f2ec swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 264
14 swift-frontend           0x00000001046b5954 generateIR(swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, llvm::GlobalVariable*&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>) + 156
15 swift-frontend           0x00000001046b03bc performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1596
16 swift-frontend           0x00000001046b306c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1748
17 swift-frontend           0x00000001046b1504 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4216
18 swift-frontend           0x0000000104676d7c swift::mainEntry(int, char const**) + 4112
19 dyld                     0x000000018c837f28 start + 2236
error: fatalError

Environment

swift-driver version: 1.82.2 Apple Swift version 5.9 (swiftlang-5.9.0.114.10 clang-1500.0.29.1)
Target: arm64-apple-macosx13.0

same crash with Xcode 14:

swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
Target: arm64-apple-macosx13.0

@KeithBauerANZ KeithBauerANZ added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Jun 22, 2023
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. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant