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

[SR-14175] @dynamicCallable with inout argument crashes compiler #56553

Open
gwynne opened this issue Feb 9, 2021 · 2 comments
Open

[SR-14175] @dynamicCallable with inout argument crashes compiler #56553

gwynne opened this issue Feb 9, 2021 · 2 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

Comments

@gwynne
Copy link
Contributor

gwynne commented Feb 9, 2021

Previous ID SR-14175
Radar rdar://problem/74148624
Original Reporter @gwynne
Type Bug
Environment

Apple Swift version 5.4 (swiftlang-1205.0.16.12 clang-1205.0.19.6)
Target: x86_64-apple-darwin19.6.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, CompilerCrash
Assignee None
Priority Medium

md5: 2aa95b4e832ba8a9e739247e13aceb32

Issue Description:

The following code reliably crashes all current versions of Swift:

@dynamicCallable struct Foo {
    func dynamicallyCall(withKeywordArguments args: KeyValuePairs<String, Any>) {}
}
var g = ""
Foo()(a: &g)

It seems that @dynamicCallable does not like inout parameters. Stack trace follows:

Stack dump:
0.  Program arguments: /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -interpret repro.swift -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk -color-diagnostics -target-sdk-version 11.1 -module-name repro
1.  Apple Swift version 5.4 (swiftlang-1205.0.16.12 clang-1205.0.19.6)
2.  While evaluating request ASTLoweringRequest(Lowering AST to SIL for module repro)
0  swift-frontend           0x000000010be98c85 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
1  swift-frontend           0x000000010be97c78 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000010be99246 SignalHandler(int) + 262
3  libsystem_platform.dylib 0x00007fff6d7125fd _sigtramp + 29
4  libsystem_platform.dylib 0x00007fe7fd500000 _sigtramp + 18446743973044083232
5  swift-frontend           0x0000000107de4b03 swift::CanTypeVisitor<(anonymous namespace)::LowerType, swift::Lowering::TypeLowering*, swift::Lowering::AbstractionPattern, swift::Lowering::IsTypeExpansionSensitive_t>::visit(swift::CanType, swift::Lowering::AbstractionPattern, swift::Lowering::IsTypeExpansionSensitive_t) + 2083
6  swift-frontend           0x0000000107de40d3 swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type, swift::TypeExpansionContext) + 1043
7  swift-frontend           0x00000001076b3860 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 38800
8  swift-frontend           0x00000001076989bd swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, llvm::Optional<swift::SILLocation>) + 125
9  swift-frontend           0x00000001076b7049 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 53113
10 swift-frontend           0x00000001076989bd swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*, llvm::Optional<swift::SILLocation>) + 125
11 swift-frontend           0x00000001076067f1 swift::Lowering::ArgumentSource::forwardInto(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, swift::Lowering::Initialization*, swift::Lowering::TypeLowering const&) && + 993
12 swift-frontend           0x00000001076c0f22 (anonymous namespace)::RValueEmitter::visitCollectionExpr(swift::CollectionExpr*, swift::Lowering::SGFContext) + 2482
13 swift-frontend           0x00000001076aa147 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 119
14 swift-frontend           0x000000010769c6a8 swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) + 40
15 swift-frontend           0x000000010764199e (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 4334
16 swift-frontend           0x000000010762b3aa (anonymous namespace)::ArgEmitter::emitSingleArg(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 170
17 swift-frontend           0x000000010764a13d (anonymous namespace)::CallEmission::emitArgumentsForNormalApply(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::SILFunctionType>, swift::Lowering::CalleeTypeInfo::ForeignInfo const&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::Optional<swift::SILLocation>&) + 2253
18 swift-frontend           0x0000000107630e7a (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 1946
19 swift-frontend           0x000000010762e8c8 swift::Lowering::SILGenFunction::emitApplyExpr(swift::ApplyExpr*, swift::Lowering::SGFContext) + 2696
20 swift-frontend           0x00000001076aa131 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 97
21 swift-frontend           0x000000010769cbd7 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 759
22 swift-frontend           0x0000000107624918 swift::ASTVisitor<swift::Lowering::SILGenModule, void, void, void, void, void, void>::visit(swift::Decl*) + 1016
23 swift-frontend           0x000000010762156e swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 4542
24 swift-frontend           0x000000010772815d 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&) + 205
25 swift-frontend           0x000000010762701c llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) + 764
26 swift-frontend           0x000000010762383f swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&) + 143
27 swift-frontend           0x000000010719edb9 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 7017
28 swift-frontend           0x0000000107128d42 main + 1266
29 libdyld.dylib            0x00007fff6d519cc9 start + 1
Segmentation fault: 11
@jckarter
Copy link
Member

jckarter commented Feb 9, 2021

@swift-ci create

@jckarter
Copy link
Member

jckarter commented Feb 9, 2021

This ought to raise an error, since keyword arguments can't capture inouts like this.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
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
Projects
None yet
Development

No branches or pull requests

3 participants