swiftlang / swift

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

This complicated combination of trailing closures and autoclosures crashes the Swift compiler #74645

Open schuelermine opened 1 week ago

schuelermine commented 1 week ago

Description

No response

Reproduction

func foo(x: @autoclosure () -> () = (), _ y: @autoclosure () -> (), z: @autoclosure () -> (), w: () -> ()) { }

foo(x: ()) { } z: { } w: { }

Stack dump

Planning build
Building for debugging...
Write auxiliary file /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift-version-575752FA6EFF9271.txt
/opt/swift-5.10.1/bin/swiftc -module-name swift_crash -emit-dependencies -emit-module -emit-module-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.swiftmodule -output-file-map /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.build/output-file-map.json -incremental -c @/home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.build/sources -I /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug -target x86_64-unknown-linux-gnu -swift-version 5 -v -enable-batch-mode -index-store-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/index/store -Onone -enable-testing -j16 -DSWIFT_PACKAGE -DDEBUG -module-cache-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -parseable-output -Xfrontend -entry-point-function-name -Xfrontend swift_crash_main -g -Xcc -fPIC -Xcc -g -package-name swift_crash -Xcc -fno-omit-frame-pointer
Swift version 5.10.1 (swift-5.10.1-RELEASE)
Target: x86_64-unknown-linux-gnu
/opt/swift-5.10.1/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /home/ubuntu/Documents/swift-crash/Sources/main.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug -enable-testing -g -module-cache-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /opt/swift-5.10.1/bin/swift-driver -entry-point-function-name swift_crash_main -empty-abi-descriptor -resource-dir /opt/swift-5.10.1/lib/swift -enable-anonymous-context-mangled-names -Xcc -fPIC -Xcc -g -Xcc -fno-omit-frame-pointer -module-name swift_crash -package-name swift_crash -plugin-path /opt/swift-5.10.1/lib/swift/host/plugins -plugin-path /opt/swift-5.10.1/local/lib/swift/host/plugins -emit-module-doc-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.swiftdoc -emit-module-source-info-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.swiftsourceinfo -emit-dependencies-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.build/swift_crash.emit-module.d -o /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.swiftmodule
/opt/swift-5.10.1/bin/swift-frontend -frontend -c -primary-file /home/ubuntu/Documents/swift-crash/Sources/main.swift -emit-dependencies-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.build/main.d -emit-reference-dependencies-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.build/main.swiftdeps -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug -enable-testing -g -module-cache-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /opt/swift-5.10.1/bin/swift-driver -entry-point-function-name swift_crash_main -empty-abi-descriptor -resource-dir /opt/swift-5.10.1/lib/swift -enable-anonymous-context-mangled-names -Xcc -fPIC -Xcc -g -Xcc -fno-omit-frame-pointer -module-name swift_crash -package-name swift_crash -plugin-path /opt/swift-5.10.1/lib/swift/host/plugins -plugin-path /opt/swift-5.10.1/local/lib/swift/host/plugins -o /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.build/main.swift.o -index-store-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/index/store -index-system-modules
error: compile command failed due to signal 6 (use -v to see invocation)
swift-frontend: /home/build-user/swift/lib/Sema/MiscDiagnostics.cpp:2154: bool swift::diagnoseArgumentLabelError(ASTContext &, const ArgumentList *, ArrayRef<Identifier>, ParameterContext, InFlightDiagnostic *): Assertion `numMissing > 0 || numExtra > 0 || numWrong > 0' failed.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.  Program arguments: /opt/swift-5.10.1/bin/swift-frontend -frontend -c -primary-file /home/ubuntu/Documents/swift-crash/Sources/main.swift -emit-dependencies-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.build/main.d -emit-reference-dependencies-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.build/main.swiftdeps -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug -enable-testing -g -module-cache-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -new-driver-path /opt/swift-5.10.1/bin/swift-driver -entry-point-function-name swift_crash_main -empty-abi-descriptor -resource-dir /opt/swift-5.10.1/lib/swift -enable-anonymous-context-mangled-names -Xcc -fPIC -Xcc -g -Xcc -fno-omit-frame-pointer -module-name swift_crash -package-name swift_crash -plugin-path /opt/swift-5.10.1/lib/swift/host/plugins -plugin-path /opt/swift-5.10.1/local/lib/swift/host/plugins -o /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/swift_crash.build/main.swift.o -index-store-path /home/ubuntu/Documents/swift-crash/.build/x86_64-unknown-linux-gnu/debug/index/store -index-system-modules
1.  Swift version 5.10.1 (swift-5.10.1-RELEASE)
2.  Compiling with the current language version
3.  While evaluating request TypeCheckSourceFileRequest(source_file "/home/ubuntu/Documents/swift-crash/Sources/main.swift")
4.  While type-checking statement at [/home/ubuntu/Documents/swift-crash/Sources/main.swift:3:1 - line:3:28] RangeText="foo(x: ()) { } z: { } w: { "
5.  While type-checking expression at [/home/ubuntu/Documents/swift-crash/Sources/main.swift:3:1 - line:3:28] RangeText="foo(x: ()) { } z: { } w: { "
6.  While type-checking-target starting at /home/ubuntu/Documents/swift-crash/Sources/main.swift:3:1
 #0 0x00005640c43dffe4 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/swift-5.10.1/bin/swift-frontend+0x72effe4)
 #1 0x00005640c43ddd4e llvm::sys::RunSignalHandlers() (/opt/swift-5.10.1/bin/swift-frontend+0x72edd4e)
 #2 0x00005640c43e0358 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f371e245320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320)
 #4 0x00007f371e29eb1c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb1c)
 #5 0x00007f371e24526e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4526e)
 #6 0x00007f371e2288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #7 0x00007f371e22881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #8 0x00007f371e23b507 (/lib/x86_64-linux-gnu/libc.so.6+0x3b507)
 #9 0x00005640bf27df8d swift::diagnoseArgumentLabelError(swift::ASTContext&, swift::ArgumentList const*, llvm::ArrayRef<swift::Identifier>, swift::ParameterContext, swift::InFlightDiagnostic*) (/opt/swift-5.10.1/bin/swift-frontend+0x218df8d)
#10 0x00005640bf1d16cc swift::constraints::RelabelArguments::diagnose(swift::constraints::Solution const&, bool) const (/opt/swift-5.10.1/bin/swift-frontend+0x20e16cc)
#11 0x00005640bf48bd1f swift::constraints::ConstraintSystem::applySolutionFixes(swift::constraints::Solution const&) (/opt/swift-5.10.1/bin/swift-frontend+0x239bd1f)
#12 0x00005640bf48c5c9 swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::constraints::SyntacticElementTarget) (/opt/swift-5.10.1/bin/swift-frontend+0x239c5c9)
#13 0x00005640bf31c738 swift::TypeChecker::typeCheckTarget(swift::constraints::SyntacticElementTarget&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) (/opt/swift-5.10.1/bin/swift-frontend+0x222c738)
#14 0x00005640bf31c56d swift::TypeChecker::typeCheckExpression(swift::constraints::SyntacticElementTarget&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) (/opt/swift-5.10.1/bin/swift-frontend+0x222c56d)
#15 0x00005640bf31c454 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::constraints::ContextualTypeInfo, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) (/opt/swift-5.10.1/bin/swift-frontend+0x222c454)
#16 0x00005640bf42c143 (anonymous namespace)::StmtChecker::typeCheckASTNode(swift::ASTNode&) TypeCheckStmt.cpp:0:0
#17 0x00005640bf42fc2d swift::ASTVisitor<(anonymous namespace)::StmtChecker, void, swift::Stmt*, void, void, void, void>::visit(swift::Stmt*) TypeCheckStmt.cpp:0:0
#18 0x00005640bf42dc6c bool (anonymous namespace)::StmtChecker::typeCheckStmt<swift::BraceStmt>(swift::BraceStmt*&) TypeCheckStmt.cpp:0:0
#19 0x00005640bf42dd01 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) (/opt/swift-5.10.1/bin/swift-frontend+0x233dd01)
#20 0x00005640bf470062 swift::TypeCheckSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile*) const (/opt/swift-5.10.1/bin/swift-frontend+0x2380062)
#21 0x00005640bf472734 llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::TypeCheckSourceFileRequest>(swift::TypeCheckSourceFileRequest const&) crtstuff.c:0:0
#22 0x00005640bf4725be llvm::Expected<swift::TypeCheckSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::TypeCheckSourceFileRequest, (void*)0>(swift::TypeCheckSourceFileRequest const&) crtstuff.c:0:0
#23 0x00005640bf46fea4 swift::TypeCheckSourceFileRequest::OutputType swift::evaluateOrDefault<swift::TypeCheckSourceFileRequest>(swift::Evaluator&, swift::TypeCheckSourceFileRequest, swift::TypeCheckSourceFileRequest::OutputType) (/opt/swift-5.10.1/bin/swift-frontend+0x237fea4)
#24 0x00005640bf46fe84 swift::performTypeChecking(swift::SourceFile&) (/opt/swift-5.10.1/bin/swift-frontend+0x237fe84)
#25 0x00005640be1c9909 bool llvm::function_ref<bool (swift::SourceFile&)>::callback_fn<swift::CompilerInstance::performSema()::$_7>(long, swift::SourceFile&) Frontend.cpp:0:0
#26 0x00005640be1be43a swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<bool (swift::SourceFile&)>) (/opt/swift-5.10.1/bin/swift-frontend+0x10ce43a)
#27 0x00005640be1be39d swift::CompilerInstance::performSema() (/opt/swift-5.10.1/bin/swift-frontend+0x10ce39d)
#28 0x00005640bdf1ed12 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) FrontendTool.cpp:0:0
#29 0x00005640bdf0c51b performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) FrontendTool.cpp:0:0
#30 0x00005640bdf0af2f swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/opt/swift-5.10.1/bin/swift-frontend+0xe1af2f)
#31 0x00005640bddb0872 swift::mainEntry(int, char const**) (/opt/swift-5.10.1/bin/swift-frontend+0xcc0872)
#32 0x00007f371e22a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#33 0x00007f371e22a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#34 0x00005640bddaf855 _start (/opt/swift-5.10.1/bin/swift-frontend+0xcbf855)

Expected behavior

I don’t actually know if this program should be accepted or not.

Environment

Swift version 5.10.1 (swift-5.10.1-RELEASE) Target: x86_64-unknown-linux-gnu

Additional information

No response

xwu commented 1 week ago

This is an interesting case. Indeed, the code is invalid, but the compiler shouldn't crash trying to diagnose it.

In the REPL on macOS, there is no crash, but I can indeed reproduce this on godbolt.org with both the nightly and Swift 5.10 compiler. It appears to be a relatively recent regression as Swift 5.9 doesn't crash but rather correctly diagnoses the problem(s).

schuelermine commented 1 week ago

Interesting. Entering the first line alone into the REPL crashes the REPL on Ubuntu.

schuelermine commented 1 week ago
ubuntu@swift:~$ swift repl -v
Swift version 5.10.1 (swift-5.10.1-RELEASE)
Target: x86_64-unknown-linux-gnu
/opt/swift-5.10.1/bin/lldb '--repl=-disable-objc-interop -color-diagnostics -new-driver-path /opt/swift-5.10.1/bin/swift-driver -empty-abi-descriptor -resource-dir /opt/swift-5.10.1/lib/swift -plugin-path /opt/swift-5.10.1/lib/swift/host/plugins -plugin-path /opt/swift-5.10.1/local/lib/swift/host/plugins'
Welcome to Swift version 5.10.1 (swift-5.10.1-RELEASE).
Type :help for assistance.
  1> func foo(x: @autoclosure () -> () = (), _ y: @autoclosure () -> (), z: @autoclosure () -> (), w: () -> ()) { }
SIL verification failed: function_ref inside fragile function cannot reference a private or hidden symbol: (SingleFunction && RefF->isExternalDeclaration()) || RefF->hasValidLinkageForFragileRef()
Verifying instruction:
->   // function_ref implicit closure #1 in default argument 0 of foo(x:_:z:w:)
  %0 = function_ref @$s13__lldb_expr_13foo1x_1z1wyyyXK_yyXKyyXKyyXEtFfA_yycfu_ : $@convention(thin) () -> () // user: %1
     %1 = thin_to_thick_function %0 : $@convention(thin) () -> () to $@callee_guaranteed () -> () // user: %2
In function:
// default argument 0 of foo(x:_:z:w:)
sil non_abi [serialized] [ossa] @$s13__lldb_expr_13foo1x_1z1wyyyXK_yyXKyyXKyyXEtFfA_ : $@convention(thin) () -> @owned @callee_guaranteed () -> () {
bb0:
  // function_ref implicit closure #1 in default argument 0 of foo(x:_:z:w:)
  %0 = function_ref @$s13__lldb_expr_13foo1x_1z1wyyyXK_yyXKyyXKyyXEtFfA_yycfu_ : $@convention(thin) () -> () // user: %1
  %1 = thin_to_thick_function %0 : $@convention(thin) () -> () to $@callee_guaranteed () -> () // user: %2
  return %1 : $@callee_guaranteed () -> ()        // id: %2
} // end sil function '$s13__lldb_expr_13foo1x_1z1wyyyXK_yyXKyyXKyyXEtFfA_'

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
 #0 0x0000564c84634ec4 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/swift-5.10.1/bin/lldb+0x28ec4)
 #1 0x0000564c8463301e llvm::sys::RunSignalHandlers() (/opt/swift-5.10.1/bin/lldb+0x2701e)
 #2 0x0000564c846354c8 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f8478245320 (/lib/x86_64-linux-gnu/libc.so.6+0x45320)
 #4 0x00007f847829eb1c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb1c)
 #5 0x00007f847824526e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4526e)
 #6 0x00007f84782288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #7 0x00007f847b24bc8e (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x284bc8e)
 #8 0x00007f847b272554 (anonymous namespace)::SILVerifier::checkFunctionRefBaseInst(swift::FunctionRefBaseInst*) SILVerifier.cpp:0:0
 #9 0x00007f847b250bd4 swift::SILVisitorBase<(anonymous namespace)::SILVerifier, void>::visitSILBasicBlock(swift::SILBasicBlock*) SILVerifier.cpp:0:0
#10 0x00007f847b2504af (anonymous namespace)::SILVerifier::visitSILBasicBlock(swift::SILBasicBlock*) SILVerifier.cpp:0:0
#11 0x00007f847b24eb2e (anonymous namespace)::SILVerifier::visitSILFunction(swift::SILFunction*) SILVerifier.cpp:0:0
#12 0x00007f847b247599 swift::SILFunction::verify(swift::SILPassManager*, bool, bool, bool) const (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x2847599)
#13 0x00007f847af833fe swift::Lowering::SILGenModule::postEmitFunction(swift::SILDeclRef, swift::SILFunction*) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x25833fe)
#14 0x00007f847af82650 swift::Lowering::SILGenModule::emitFunctionDefinition(swift::SILDeclRef, swift::SILFunction*) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x2582650)
#15 0x00007f847af83c6f swift::Lowering::SILGenModule::emitOrDelayFunction(swift::SILDeclRef) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x2583c6f)
#16 0x00007f847af84bfe swift::Lowering::SILGenModule::emitArgumentGenerators(llvm::PointerUnion<swift::ValueDecl*, swift::AbstractClosureExpr*, swift::FileUnit*>, swift::ParameterList*) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x2584bfe)
#17 0x00007f847af847fc swift::Lowering::SILGenModule::emitAbstractFuncDecl(swift::AbstractFunctionDecl*) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x25847fc)
#18 0x00007f847af81242 swift::Lowering::SILGenModule::emitFunction(swift::FuncDecl*) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x2581242)
#19 0x00007f847af86d67 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x2586d67)
#20 0x00007f847b05ee0b swift::SimpleRequest<swift::ASTLoweringRequest, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>> (swift::ASTLoweringDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::ASTLoweringRequest const&, swift::Evaluator&) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x265ee0b)
#21 0x00007f847aa0adb3 llvm::Expected<swift::ASTLoweringRequest::OutputType> swift::Evaluator::getResultUncached<swift::ASTLoweringRequest>(swift::ASTLoweringRequest const&) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x200adb3)
#22 0x00007f847af878c8 swift::performASTLowering(swift::FileUnit&, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x25878c8)
#23 0x00007f847a242de3 lldb_private::SwiftExpressionParser::Parse(lldb_private::DiagnosticManager&, unsigned int, unsigned int) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x1842de3)
#24 0x00007f847a23a4c5 lldb_private::SwiftUserExpression::GetTextAndSetExpressionParser(lldb_private::DiagnosticManager&, std::unique_ptr<lldb_private::SwiftExpressionSourceCode, std::default_delete<lldb_private::SwiftExpressionSourceCode>>&, lldb_private::ExecutionContext&, lldb_private::ExecutionContextScope*) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x183a4c5)
#25 0x00007f847a23b507 lldb_private::SwiftUserExpression::Parse(lldb_private::DiagnosticManager&, lldb_private::ExecutionContext&, lldb_private::ExecutionPolicy, bool, bool) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x183b507)
#26 0x00007f8479a802f2 lldb_private::UserExpression::Evaluate(lldb_private::ExecutionContext&, lldb_private::EvaluateExpressionOptions const&, llvm::StringRef, llvm::StringRef, std::shared_ptr<lldb_private::ValueObject>&, lldb_private::Status&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, lldb_private::ValueObject*) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x10802f2)
#27 0x00007f8479a7c9d2 lldb_private::REPL::IOHandlerInputComplete(lldb_private::IOHandler&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x107c9d2)
#28 0x00007f8479a039f9 lldb_private::IOHandlerEditline::Run() (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x10039f9)
#29 0x00007f84799e23a6 lldb_private::Debugger::RunIOHandlers() (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0xfe23a6)
#30 0x00007f84799ea342 std::_Function_handler<void* (), lldb_private::Debugger::StartIOHandlerThread()::$_4>::_M_invoke(std::_Any_data const&) Debugger.cpp:0:0
#31 0x00007f8479aae060 lldb_private::HostNativeThreadBase::ThreadCreateTrampoline(void*) (/opt/swift-5.10.1/bin/../lib/liblldb.so.15git+0x10ae060)
#32 0x00007f847829ca94 (/lib/x86_64-linux-gnu/libc.so.6+0x9ca94)
#33 0x00007f8478329c3c (/lib/x86_64-linux-gnu/libc.so.6+0x129c3c)
Aborted (core dumped)
hamishknight commented 1 week ago

Looks like you don't even need the autoclosure to reproduce, this also crashes:

func foo(_ y: Int, w: () -> ()) { }
foo { } w: { }