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

Isolated parameter to struct init crashes in silgen #71174

Closed
tgoyne opened this issue Jan 26, 2024 · 1 comment
Closed

Isolated parameter to struct init crashes in silgen #71174

tgoyne opened this issue Jan 26, 2024 · 1 comment
Assignees
Labels
actor isolation Feature → concurrency: Actor isolation bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. concurrency Feature: umbrella label for concurrency language features crash Bug: A crash, i.e., an abnormal termination of software

Comments

@tgoyne
Copy link

tgoyne commented Jan 26, 2024

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

@tgoyne tgoyne added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels Jan 26, 2024
@hborla hborla added concurrency Feature: umbrella label for concurrency language features actor isolation Feature → concurrency: Actor isolation and removed triage needed This issue needs more specific labels labels Jan 26, 2024
@hborla
Copy link
Member

hborla commented Jan 26, 2024

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.

@hborla hborla self-assigned this Jan 29, 2024
niw added a commit to niw/swift that referenced this issue Apr 24, 2024
Try to workaround swiftlang#71174.
I have no idea what I am doing.
niw added a commit to niw/swift that referenced this issue Apr 24, 2024
Try to workaround swiftlang#71174, which crashes Swift with
an async initializer with isolated actor argument.

I have no idea what I am doing.
@hborla hborla assigned rjmccall and unassigned hborla Jul 14, 2024
@hborla hborla closed this as completed Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actor isolation Feature → concurrency: Actor isolation bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. concurrency Feature: umbrella label for concurrency language features crash Bug: A crash, i.e., an abnormal termination of software
Projects
None yet
Development

No branches or pull requests

3 participants