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 init crashes the compiler #74359

Closed
tgoyne opened this issue Jun 12, 2024 · 3 comments
Closed

Isolated init crashes the compiler #74359

tgoyne opened this issue Jun 12, 2024 · 3 comments
Assignees
Labels
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 Jun 12, 2024

Description

All of the forms I could think of to write an async init which is isolated to a parameter simply crash.

Reproduction

struct Foo {
    init(actor: isolated MainActor) async {}
    // All of the following forms also produce the same crash:
    // init<A: Actor>(actor: isolated A) async {}
    // init(actor: isolated some Actor) async {}
    // init(actor: isolated any Actor) async {}
    // init(actor: isolated (any Actor)? = #isolation) async {}
}
Task { @MainActor in
    await Foo(actor: MainActor.shared)
}

Stack dump

0.	Program arguments: /Applications/Xcode-16.0.0-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -interpret foo.swift -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode-16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.0.sdk -color-diagnostics -new-driver-path /Applications/Xcode-16.0.0-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Applications/Xcode-16.0.0-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -module-name foo -disable-clang-spi -target-sdk-version 15.0 -target-sdk-name macosx15.0 -external-plugin-path /Applications/Xcode-16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode-16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode-16.0.0-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode-16.0.0-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode-16.0.0-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins
1.	Apple Swift version 6.0 (swiftlang-6.0.0.3.300 clang-1600.0.20.10)
2.	Compiling with effective version 5.10
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module foo)
4.	While silgen emitValueConstructor SIL function "@$s3foo3FooV5actorACScMYi_tYacfC".
 for 'init(actor:)' (at foo.swift:2: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           0x0000000105d22cd0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000105d20f44 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000105d232d8 SignalHandler(int) + 352
3  libsystem_platform.dylib 0x00000001806af584 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018067ec20 pthread_kill + 288
5  libsystem_c.dylib        0x000000018058ba30 abort + 180
6  swift-frontend           0x000000010067841c swift::Diagnostic::operator=(swift::Diagnostic const&) + 0
7  swift-frontend           0x0000000101153f90 swift::Lowering::SILGenFunction::emitMainExecutor(swift::SILLocation) + 0
8  swift-frontend           0x0000000101153ca0 swift::Lowering::SILGenFunction::emitConstructorPrologActorHop(swift::SILLocation, std::__1::optional<swift::ActorIsolation>) + 84
9  swift-frontend           0x000000010115648c swift::Lowering::SILGenFunction::emitValueConstructor(swift::ConstructorDecl*) + 2204
10 swift-frontend           0x0000000101103098 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 7428
11 swift-frontend           0x0000000101103c2c swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 212
12 swift-frontend           0x0000000101104c64 swift::Lowering::SILGenModule::emitConstructor(swift::ConstructorDecl*) + 380
13 swift-frontend           0x00000001012349d4 (anonymous namespace)::SILGenType::emitType() + 564
14 swift-frontend           0x0000000101101078 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 104
15 swift-frontend           0x0000000101107200 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1804
16 swift-frontend           0x000000010121ee68 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
17 swift-frontend           0x000000010110c0f4 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'()) + 524
18 swift-frontend           0x00000001006ed6a8 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2484
19 swift-frontend           0x00000001006f1938 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2904
20 swift-frontend           0x00000001006ef438 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4752
21 swift-frontend           0x00000001006752d8 swift::mainEntry(int, char const**) + 2812
22 dyld                     0x00000001802f60e0 start + 2360
[1]    7875 abort      DEVELOPER_DIR=/Applications/Xcode-16.0.0-beta.app swift foo.swift

Expected behavior

It should compile correctly and run the init on the actor's executor.

Environment

swift-driver version: 1.109.2 Apple Swift version 6.0 (swiftlang-6.0.0.3.300 clang-1600.0.20.10)
Target: arm64-apple-macosx14.0

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 Jun 12, 2024
@hborla hborla added concurrency Feature: umbrella label for concurrency language features and removed triage needed This issue needs more specific labels labels Jul 14, 2024
@hborla
Copy link
Member

hborla commented Jul 14, 2024

I'm pretty sure this is a dupe of an issue you've already filed

@hborla
Copy link
Member

hborla commented Jul 14, 2024

Duplicate of #71174

@hborla hborla marked this as a duplicate of #71174 Jul 14, 2024
@hborla hborla closed this as completed Jul 14, 2024
@tgoyne
Copy link
Author

tgoyne commented Jul 15, 2024

Huh, I totally forgot that I'd tried it previously.

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. 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