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

Compiler crashes when calling assumeIsolated on an actor instance that is a parameterized protocol type where the parameter is generic #78442

Closed
TheHarcker opened this issue Jan 5, 2025 · 2 comments
Labels
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

Comments

@TheHarcker
Copy link
Contributor

Description

The swift compiler crashes when compiling the snippet below.

Reproduction

protocol A<B>: Actor {
    associatedtype B
}

func someGenericContext<C>(a: any A<C>) {
    a.assumeIsolated { _ in true }
}

Stack dump

0.	Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file Sources/POC-Swift-crash/POC_Swift_crash.swift -target arm64-apple-macosx15.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -color-diagnostics -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -module-name POC_Swift_crash -disable-clang-spi -target-sdk-version 15.2 -target-sdk-name macosx15.2 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -o /var/folders/br/_96cjb497ngb81vl5_zn5rz80000gn/T/TemporaryDirectory.5lCu06/POC_Swift_crash-1.o
1.	Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
2.	Compiling with effective version 5.10
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "Sources/POC-Swift-crash/POC_Swift_crash.swift")
4.	While silgen emitFunction SIL function "@$s15POC_Swift_crash18someGenericContext1ayAA1A_px1BRts_XP_tlF".
 for 'someGenericContext(a:)' (at Sources/POC-Swift-crash/POC_Swift_crash.swift:5: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           0x0000000109f16a9c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000109f14cf0 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000109f17068 SignalHandler(int) + 292
3  libsystem_platform.dylib 0x0000000188bf2e04 _sigtramp + 56
4  swift-frontend           0x0000000105f9e33c swift::Mangle::ASTMangler::appendRequirement(swift::Requirement const&, swift::GenericSignature, bool) + 136
5  swift-frontend           0x0000000105f9e33c swift::Mangle::ASTMangler::appendRequirement(swift::Requirement const&, swift::GenericSignature, bool) + 136
6  swift-frontend           0x0000000105f9c800 swift::Mangle::ASTMangler::appendGenericSignatureParts(swift::GenericSignature, swift::Mangle::ASTMangler::GenericSignatureParts const&) + 196
7  swift-frontend           0x0000000105f8f400 swift::Mangle::ASTMangler::appendGenericSignature(swift::GenericSignature) + 168
8  swift-frontend           0x0000000105f9100c swift::Mangle::ASTMangler::mangleReabstractionThunkHelper(swift::CanTypeWrapper<swift::SILFunctionType>, swift::Type, swift::Type, swift::Type, swift::Type, swift::ModuleDecl*) + 200
9  swift-frontend           0x000000010542297c swift::Lowering::SILGenModule::getOrCreateReabstractionThunk(swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanTypeWrapper<swift::SILFunctionType>, swift::CanType, swift::CanType) + 1216
10 swift-frontend           0x00000001053f9054 createThunk(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::TypeLowering const&) + 3472
11 swift-frontend           0x00000001053ee8fc (anonymous namespace)::Transform::transform(swift::Lowering::ManagedValue, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType, swift::SILType, swift::Lowering::SGFContext) + 1700
12 swift-frontend           0x000000010533f7a4 swift::Lowering::Conversion::emit(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Lowering::SGFContext) const + 472
13 swift-frontend           0x000000010533f278 swift::Lowering::SILGenFunction::emitConvertedRValue(swift::SILLocation, swift::Lowering::Conversion const&, swift::Lowering::SGFContext, llvm::function_ref<swift::Lowering::ManagedValue (swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::SGFContext)>) + 384
14 swift-frontend           0x000000010533f43c swift::Lowering::ConvertingInitialization::tryPeephole(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::Conversion, llvm::function_ref<swift::Lowering::ManagedValue (swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::SGFContext)>) + 360
15 swift-frontend           0x000000010533f198 swift::Lowering::SILGenFunction::emitConvertedRValue(swift::SILLocation, swift::Lowering::Conversion const&, swift::Lowering::SGFContext, llvm::function_ref<swift::Lowering::ManagedValue (swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::SGFContext)>) + 160
16 swift-frontend           0x0000000105376bc8 (anonymous namespace)::RValueEmitter::visitFunctionConversionExpr(swift::FunctionConversionExpr*, swift::Lowering::SGFContext) + 2000
17 swift-frontend           0x000000010535f58c swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) + 40
18 swift-frontend           0x000000010533f234 swift::Lowering::SILGenFunction::emitConvertedRValue(swift::SILLocation, swift::Lowering::Conversion const&, swift::Lowering::SGFContext, llvm::function_ref<swift::Lowering::ManagedValue (swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::SGFContext)>) + 316
19 swift-frontend           0x00000001052bee74 swift::Lowering::ArgumentSource::getConverted(swift::Lowering::SILGenFunction&, swift::Lowering::Conversion const&, swift::Lowering::SGFContext) && + 136
20 swift-frontend           0x00000001052fe25c (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern, std::__1::optional<swift::AnyFunctionType::Param>) + 5528
21 swift-frontend           0x00000001052ec0f0 (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern, std::__1::optional<swift::AnyFunctionType::Param>) + 216
22 swift-frontend           0x00000001052fc9ac (anonymous namespace)::ArgEmitter::emitPreparedArgs(swift::Lowering::PreparedArguments&&, swift::Lowering::AbstractionPattern) + 256
23 swift-frontend           0x0000000105308878 (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<(anonymous namespace)::DelayedArgument>&, swift::ForeignInfo const&) && + 664
24 swift-frontend           0x0000000105308298 (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, swift::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, std::__1::optional<swift::SILLocation>&) + 1000
25 swift-frontend           0x00000001052f0e7c (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 2028
26 swift-frontend           0x00000001052ef408 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 3116
27 swift-frontend           0x0000000105385390 void llvm::function_ref<void (swift::Expr*)>::callback_fn<swift::Lowering::RValue swift::Lowering::SILGenFunction::emitOpenExistentialExpr<swift::Lowering::RValue, (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext)::$_0>(swift::OpenExistentialExpr*, (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext)::$_0)::'lambda'(swift::Expr*)>(long, swift::Expr*) + 36
28 swift-frontend           0x00000001053693e4 swift::Lowering::SILGenFunction::emitOpenExistentialExprImpl(swift::OpenExistentialExpr*, llvm::function_ref<void (swift::Expr*)>) + 812
29 swift-frontend           0x0000000105375894 (anonymous namespace)::RValueEmitter::visitOpenExistentialExpr(swift::OpenExistentialExpr*, swift::Lowering::SGFContext) + 272
30 swift-frontend           0x000000010535fc74 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 888
31 swift-frontend           0x0000000105417274 swift::ASTVisitor<(anonymous namespace)::StmtEmitter, void, void, void, void, void, void>::visit(swift::Stmt*) + 5512
32 swift-frontend           0x000000010538efc8 swift::Lowering::SILGenFunction::emitFunction(swift::FuncDecl*) + 492
33 swift-frontend           0x00000001052dab1c swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) + 8420
34 swift-frontend           0x00000001052db3bc swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) + 216
35 swift-frontend           0x00000001052d89ec swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) + 364
36 swift-frontend           0x00000001052df038 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 1804
37 swift-frontend           0x000000010541592c 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
38 swift-frontend           0x00000001052e3f14 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'()) + 528
39 swift-frontend           0x00000001048bdb90 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 920
40 swift-frontend           0x00000001048c0e88 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1684
41 swift-frontend           0x00000001048bfbb4 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3572
42 swift-frontend           0x0000000104846a5c swift::mainEntry(int, char const**) + 3680
43 dyld                     0x000000018883c274 start + 2840

Expected behavior

I expected the code to compile successfully.

Environment

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0

Additional information

No response

@TheHarcker TheHarcker 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 5, 2025
@bc-lee
Copy link
Contributor

bc-lee commented Jan 6, 2025

Not reproducible on swift-6.1-DEVELOPMENT-SNAPSHOT-2025-01-03-a or swift-DEVELOPMENT-SNAPSHOT-2025-01-03-a. It seems to have been fixed.

@TheHarcker
Copy link
Contributor Author

When using the latest toolchains (swift-6.1-DEVELOPMENT-SNAPSHOT-2025-01-17-a and swift-DEVELOPMENT-SNAPSHOT-2025-01-10-a) , I'm also unable to reproduce the crash.

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. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

2 participants