swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.58k stars 10.36k forks source link

Isolated parameter to struct init crashes in silgen #71174

Open tgoyne opened 9 months ago

tgoyne commented 9 months ago

Description

No response

Reproduction

struct Foo {
    init<A: Actor>(actor: isolated A) async {
    }
}

Stack dump

0  swift-frontend           0x00000001065d7d8c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x00000001065d6f48 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x00000001065d8394 SignalHandler(int) + 360
3  libsystem_platform.dylib 0x0000000184355a24 _sigtramp + 56
4  swift-frontend           0x00000001016034e4 swift::Lowering::SILGenFunction::emitLoadActorExecutor(swift::SILLocation, swift::Lowering::ManagedValue) + 140
5  swift-frontend           0x00000001016034e4 swift::Lowering::SILGenFunction::emitLoadActorExecutor(swift::SILLocation, swift::Lowering::ManagedValue) + 140
6  swift-frontend           0x0000000101548194 swift::Lowering::SILGenFunction::emitValueConstructor(swift::ConstructorDecl*) + 10020
7  swift-frontend           0x00000001014f8aa8 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 7512
8  swift-frontend           0x00000001014f955c swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 172
9  swift-frontend           0x00000001014fa608 swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*) + 336
10 swift-frontend           0x000000010161db28 (anonymous namespace)::SILGenType::emitType() + 752
11 swift-frontend           0x00000001014f6958 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 104
12 swift-frontend           0x00000001014fcaf4 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1668
13 swift-frontend           0x000000010160c138 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&) + 196
14 swift-frontend           0x00000001014ffee4 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 584
15 swift-frontend           0x00000001014fd7f4 swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 152
16 swift-frontend           0x0000000100ed757c swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2068
17 swift-frontend           0x0000000100edb9cc performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 3616
18 swift-frontend           0x0000000100ed91e0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4852
19 swift-frontend           0x0000000100e689f4 swift::mainEntry(int, char const**) + 2612
20 dyld                     0x0000000183fa50e0 start + 2360

Expected behavior

The initializer should be isolated to the given parameter.

Environment

swift-driver version: 1.90.8 Apple Swift version 5.10 (swiftlang-5.10.0.10.5 clang-1500.3.7.4)

Tested with Xcode 15.3 beta 1 and the toolchain from https://ci.swift.org/job/swift-PR-toolchain-macos/1041/.

Additional information

No response

hborla commented 9 months ago

Thanks for the report! It looks like constructor prolog emission goes through a different code path than regular functions, and the hop_to_executor emission in the constructor case has never handled isolated parameters.