-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
I have a protocol that includes a function involving a parameter pack that returns a parameter pack of associatedtypes. If I call that function inside a function that takes a generic version of that protocol the compiler crashes
Reproduction
protocol ThingProtocol {
associatedtype Response
func process() -> Response
}
struct Thing: ThingProtocol {
func process() -> String {
return "Hello"
}
}
protocol ThingProcessorProtocol {
func process<each P: ThingProtocol>(_ params: repeat each P) -> (repeat (each P).Response)
}
struct ThingProcessor: ThingProcessorProtocol {
func process<each P: ThingProtocol>(_ params: repeat each P) -> (repeat (each P).Response) {
return (repeat (each params).process())
}
}
func test(_ this: some ThingProcessorProtocol) {
let result = this.process(Thing(), Thing())
print(result.0)
}
test(ThingProcessor())
Stack dump
> /usr/bin/swift -swift-version 6 /tmp/vscode-swift/Untitled-1aed661a9a12d6.swift
Stack dump:
0. Program arguments: /usr/bin/swift-frontend -frontend -interpret /tmp/vscode-swift/Untitled-1aed661a9a12d6.swift -Xllvm -aarch64-use-tbi -disable-objc-interop -color-diagnostics -Xcc -fcolor-diagnostics -swift-version 6 -empty-abi-descriptor -no-auto-bridging-header-chaining -module-name main -in-process-plugin-server-path /usr/lib/swift/host/libSwiftInProcPluginServer.so -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins
1. Swift version 6.2 (swift-6.2-RELEASE)
2. Compiling with the current language version
3. While evaluating request ASTLoweringRequest(Lowering AST to SIL for module main)
4. While silgen emitFunction SIL function "@$s4main4testyyxAA22ThingProcessorProtocolRzlF".
for 'test(_:)' (at /tmp/vscode-swift/Untitled-1aed661a9a12d6.swift:23:1)
#0 0x0000aaaab2db6820 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/bin/swift-frontend+0x6b36820)
#1 0x0000aaaab2db4820 llvm::sys::RunSignalHandlers() (/usr/bin/swift-frontend+0x6b34820)
#2 0x0000aaaab2db6f34 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x0000ffffbb63b790 (linux-vdso.so.1+0x790)
#4 0x0000aaaaad4f5620 swift::Lowering::ManagedValue::ensurePlusOne(swift::Lowering::SILGenFunction&, swift::SILLocation) const (/usr/bin/swift-frontend+0x1275620)
#5 0x0000aaaaad4ffbc8 (anonymous namespace)::ImplodeLoadableTupleValue<((anonymous namespace)::ImplodeKind)1>::visitTupleType(swift::CanTypeWrapper<swift::TupleType>, swift::SILLocation) RValue.cpp:0:0
#6 0x0000aaaaad4fbe00 swift::Lowering::ManagedValue implodeTupleValues<((anonymous namespace)::ImplodeKind)1>(llvm::ArrayRef<swift::Lowering::ManagedValue>, swift::Lowering::SILGenFunction&, swift::CanType, swift::SILLocation) RValue.cpp:0:0
#7 0x0000aaaaad4fb274 swift::Lowering::RValue::getAsSingleValue(swift::Lowering::SILGenFunction&, swift::SILLocation) && (/usr/bin/swift-frontend+0x127b274)
#8 0x0000aaaaad4fa7f4 (anonymous namespace)::InitValueFromRValueResultPlan::finish(swift::Lowering::SILGenFunction&, swift::SILLocation, llvm::ArrayRef<swift::Lowering::ManagedValue>&, swift::SILValue) ResultPlan.cpp:0:0
#9 0x0000aaaaad506058 swift::Lowering::SILGenFunction::emitApply(std::unique_ptr<swift::Lowering::ResultPlan, std::default_delete<swift::Lowering::ResultPlan>>&&, swift::Lowering::ArgumentScope&&, swift::SILLocation, swift::Lowering::ManagedValue, swift::SubstitutionMap, llvm::ArrayRef<swift::Lowering::ManagedValue>, swift::Lowering::CalleeTypeInfo const&, swift::optionset::OptionSet<swift::ApplyFlags, unsigned char>, swift::Lowering::SGFContext, std::optional<swift::ActorIsolation>) crtstuff.c:0:0
#10 0x0000aaaaad50b1e8 (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) SILGenApply.cpp:0:0
#11 0x0000aaaaad509aa8 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) crtstuff.c:0:0
#12 0x0000aaaaad45e668 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, std::optional<swift::SILLocation>) crtstuff.c:0:0
#13 0x0000aaaaad44dba0 swift::Lowering::SILGenFunction::emitPatternBinding(swift::PatternBindingDecl*, unsigned int, bool) crtstuff.c:0:0
#14 0x0000aaaaad453d14 swift::ASTVisitor<swift::Lowering::SILGenFunction, void, void, void, void, void, void>::visit(swift::Decl*) crtstuff.c:0:0
#15 0x0000aaaaad4dc75c swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) SILGenStmt.cpp:0:0
#16 0x0000aaaaad4db614 swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) crtstuff.c:0:0
#17 0x0000aaaaad483130 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) crtstuff.c:0:0
#18 0x0000aaaaad421078 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) crtstuff.c:0:0
#19 0x0000aaaaad421b0c swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) crtstuff.c:0:0
#20 0x0000aaaaad41f828 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) crtstuff.c:0:0
#21 0x0000aaaaad423e44 swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*) crtstuff.c:0:0
#22 0x0000aaaaad4243e4 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const (/usr/bin/swift-frontend+0x11a43e4)
#23 0x0000aaaaad4dafdc std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>> swift::SimpleRequest<swift::ASTLoweringRequest, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)17>::callDerived<0ul>(swift::Evaluator&, std::integer_sequence<unsigned long, 0ul>) const crtstuff.c:0:0
#24 0x0000aaaaad42870c swift::ASTLoweringRequest::OutputType swift::Evaluator::getResultUncached<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) crtstuff.c:0:0
#25 0x0000aaaaad424750 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) (/usr/bin/swift-frontend+0x11a4750)
#26 0x0000aaaaacde77d4 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) (/usr/bin/swift-frontend+0xb677d4)
#27 0x0000aaaaacdf3f24 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) FrontendTool.cpp:0:0
#28 0x0000aaaaacdea2c0 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) FrontendTool.cpp:0:0
#29 0x0000aaaaacde8ff4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/usr/bin/swift-frontend+0xb68ff4)
#30 0x0000aaaaacbcf0b0 swift::mainEntry(int, char const**) (/usr/bin/swift-frontend+0x94f0b0)
#31 0x0000ffffb97684c4 (/lib/aarch64-linux-gnu/libc.so.6+0x284c4)
#32 0x0000ffffb9768598 __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x28598)
#33 0x0000aaaaacbcdbf0 _start (/usr/bin/swift-frontend+0x94dbf0)
💣 Program crashed: Bad pointer dereference at 0x000003e80000c68b
Expected behavior
Compiler doesn't crash
Environment
Swift version 6.2 (swift-6.2-RELEASE)
Target: aarch64-unknown-linux-gnu
Additional information
No response
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labelsThis issue needs more specific labels