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

SILGen crash on try repeat/await repeat #73263

Open
AnthonyLatsis opened this issue Apr 25, 2024 · 0 comments
Open

SILGen crash on try repeat/await repeat #73263

AnthonyLatsis opened this issue Apr 25, 2024 · 0 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 expressions Feature: expressions generics Feature: generic declarations and types pack expansions Feature → expressions: Pack expansion expressions SILGen Area → compiler: The SIL generation stage swift 6.0 variadic generics Feature → generics: Variadic generics

Comments

@AnthonyLatsis
Copy link
Collaborator

Description

No response

Reproduction

func blackHole<T>(_: T) throws {}

func foo<each T>(_ t: repeat each T) throws {
  try repeat blackHole(each t)
}

Ditto await repeat.

Stack dump

Assertion failed: (init && init->canPerformPackExpansionInitialization() && "cannot emit a PackExpansionExpr without an appropriate context"), function visitPackExpansionExpr, file SILGenExpr.cpp, line 1646.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: bin/swift-frontend -debug-diagnostic-names -diagnostic-style=llvm -emit-sil -enable-experimental-feature NoncopyableGenerics /Users/mac/Desktop/test.swift
1.	Swift version 6.0-dev (LLVM beb75c68bf9e0fb, Swift eb40cc56777bae4)
2.	Compiling with effective version 5.10
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module test)
4.	While silgen emitFunction SIL function "@$s4test3fooyyxxQpKRvzlF".
 for 'foo(_:)' (at /Users/mac/Desktop/test.swift:234:1)
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           0x000000010a53e7e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
1  swift-frontend           0x000000010a53cc35 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x000000010a53ee3e SignalHandler(int) + 270
3  libsystem_platform.dylib 0x00007ff8058ea37d _sigtramp + 29
4  swift-frontend           0x000000010e06e9b8 swift::AnyRequestVTable const* swift::AnyRequestVTable::get<swift::LookupConformanceInModuleRequest>()::vtable + 72
5  libsystem_c.dylib        0x00007ff8057dba4d abort + 126
6  libsystem_c.dylib        0x00007ff8057dad60 err + 0
7  swift-frontend           0x0000000102bfb598 (anonymous namespace)::RValueEmitter::visitPackExpansionExpr(swift::PackExpansionExpr*, swift::Lowering::SGFContext) + 200
8  swift-frontend           0x0000000102be5cb6 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 2470
9  swift-frontend           0x0000000102bf939e swift::Lowering::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, swift::Lowering::SGFContext>::visitTryExpr(swift::TryExpr*, swift::Lowering::SGFContext) + 94
10 swift-frontend           0x0000000102be59bf swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 1711
11 swift-frontend           0x0000000102bd5d11 swift::Lowering::SILGenFunction::emitRValue(swift::Expr*, swift::Lowering::SGFContext) + 209
12 swift-frontend           0x0000000102bdb874 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 2020
13 swift-frontend           0x0000000102d2f90f (anonymous namespace)::StmtEmitter::visitBraceStmt(swift::BraceStmt*) + 2271
14 swift-frontend           0x0000000102d29491 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 81
15 swift-frontend           0x0000000102d2940a swift::Lowering::SILGenFunction::emitStmt(swift::Stmt*) + 42
16 swift-frontend           0x0000000102c3225c swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 956
17 swift-frontend           0x0000000102ab8530 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 4512
18 swift-frontend           0x0000000102abbc15 swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 533
19 swift-frontend           0x0000000102ab7362 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 450
20 swift-frontend           0x0000000102ab718d swift::Lowering::SILGenModule::visitFuncDecl(swift::FuncDecl*) + 29
21 swift-frontend           0x0000000102ab6e54 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 996
22 swift-frontend           0x0000000102ab6a60 swift::Lowering::SILGenModule::visit(swift::Decl*) + 64
23 swift-frontend           0x0000000102ac0dc4 (anonymous namespace)::SILGenModuleRAII::emitSourceFile(swift::SourceFile*) + 340
24 swift-frontend           0x0000000102ac096f swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 879
25 swift-frontend           0x0000000102d285de std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::callDerived<0ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul>) const + 142
26 swift-frontend           0x0000000102d284f8 swift::SimpleRequest<swift::ASTLoweringRequest, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) + 40
27 swift-frontend           0x0000000102adcb18 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'()) + 264
28 swift-frontend           0x0000000102adc9f8 swift::ASTLoweringRequest::OutputType swift::Evaluator::operator()<swift::ASTLoweringRequest, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'(), (void*)0>(swift::ASTLoweringRequest const&, swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest)::'lambda'()) + 40
29 swift-frontend           0x0000000102ac1584 swift::ASTLoweringRequest::OutputType swift::evaluateOrFatal<swift::ASTLoweringRequest>(swift::Evaluator&, swift::ASTLoweringRequest) + 36
30 swift-frontend           0x0000000102ac14a0 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 256
31 swift-frontend           0x0000000101cf95bb swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 283
32 swift-frontend           0x0000000101d2ad83 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_29::operator()(swift::CompilerInstance&) const + 147
33 swift-frontend           0x0000000101d2acdd bool llvm::function_ref<bool (swift::CompilerInstance&)>::callback_fn<performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*)::$_29>(long, swift::CompilerInstance&) + 29
34 swift-frontend           0x0000000101d2a0a1 llvm::function_ref<bool (swift::CompilerInstance&)>::operator()(swift::CompilerInstance&) const + 33
35 swift-frontend           0x0000000101d29038 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 392
36 swift-frontend           0x0000000101d21555 performAction(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1349
37 swift-frontend           0x0000000101cfca66 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 262
38 swift-frontend           0x0000000101cfb44a swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2794
39 swift-frontend           0x0000000101ba97ea run_driver(llvm::StringRef, llvm::ArrayRef<char const*>, llvm::ArrayRef<char const*>) + 2410
40 swift-frontend           0x0000000101ba8427 swift::mainEntry(int, char const**) + 1543
41 swift-frontend           0x0000000101ba7952 main + 34
42 dyld                     0x00007ff8055343a6 start + 1942
Abort trap: 6

Expected behavior

Handle as repeat try/repeat await or ban this keyword permutation if the former poses a substantial technical problem.

Environment

Swift version 6.0-dev (LLVM beb75c68bf9e0fb, Swift eb40cc5)
Target: x86_64-apple-macosx14.0

Additional information

No response

@AnthonyLatsis AnthonyLatsis added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself SILGen Area → compiler: The SIL generation stage generics Feature: generic declarations and types crash Bug: A crash, i.e., an abnormal termination of software expressions Feature: expressions variadic generics Feature → generics: Variadic generics pack expansions Feature → expressions: Pack expansion expressions swift 6.0 labels Apr 25, 2024
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 expressions Feature: expressions generics Feature: generic declarations and types pack expansions Feature → expressions: Pack expansion expressions SILGen Area → compiler: The SIL generation stage swift 6.0 variadic generics Feature → generics: Variadic generics
Projects
None yet
Development

No branches or pull requests

1 participant