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

Parameter pack compilation crash "This isn't an lvalue" with 6.0.3 OSS toolchain but works with Xcode toolchain #79870

Open
marcprux opened this issue Mar 9, 2025 · 0 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

@marcprux
Copy link
Contributor

marcprux commented Mar 9, 2025

Description

When attempting to build the parameter pack code in Reproduction, the Swift 6.0.3 OSS toolchain (~/Library/Developer/Toolchains/swift-6.0.3-RELEASE.xctoolchain/usr/bin/swift build) crashes, but the Swift 6.0.3 toolchain bundled with Xcode 16.2 (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift build) builds fine.

Likely related to #78693 and #78671.

This was reported on our Slack (https://skiptools.slack.com/archives/C07MLMD57ST/p1741494643312329) when building for Android, which uses the OSS host toolchain.

Reproduction

@available(macOS 14, *)
public struct TupleComponent<each T: Component>: Component {
    public func write(_ data: (repeat (each T).Content)) { }
}

public protocol Component<Content> {
    associatedtype Content 
    func write(_ data: Content)
}

Stack dump

error: emit-module command failed due to signal 6 (use -v to see invocation)
Assertion failed: (isLValue() && "This isn't an lvalue"), function getLValueAddress, file ManagedValue.h, line 318.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/marc/Library/Developer/Toolchains/swift-6.0.3-RELEASE.xctoolchain/usr/bin/swift-frontend -frontend -emit-module -experimental-skip-non-inlinable-function-bodies-without-types /private/tmp/TupleDemo/Sources/TupleDemo/TupleDemo.swift -target arm64-apple-macosx10.13 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -I /private/tmp/TupleDemo/.build/arm64-apple-macosx/debug/Modules -I /Users/marc/Library/Developer/Toolchains/swift-6.0.3-RELEASE.xctoolchain/usr/lib/swift/macosx/testing -I /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /private/tmp/TupleDemo/.build/arm64-apple-macosx/debug/ModuleCache -swift-version 6 -Onone -D SWIFT_PACKAGE -D DEBUG -empty-abi-descriptor -plugin-path /Users/marc/Library/Developer/Toolchains/swift-6.0.3-RELEASE.xctoolchain/usr/lib/swift/host/plugins/testing -resource-dir /Users/marc/Library/Developer/Toolchains/swift-6.0.3-RELEASE.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /private/tmp/TupleDemo -Xcc -isysroot -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX15.2.sdk -Xcc -F -Xcc /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC -Xcc -g -module-name TupleDemo -package-name tupledemo -plugin-path /Users/marc/Library/Developer/Toolchains/swift-6.0.3-RELEASE.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/marc/Library/Developer/Toolchains/swift-6.0.3-RELEASE.xctoolchain/usr/local/lib/swift/host/plugins -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 -emit-module-doc-path /private/tmp/TupleDemo/.build/arm64-apple-macosx/debug/Modules/TupleDemo.swiftdoc -emit-module-source-info-path /private/tmp/TupleDemo/.build/arm64-apple-macosx/debug/Modules/TupleDemo.swiftsourceinfo -emit-objc-header-path /private/tmp/TupleDemo/.build/arm64-apple-macosx/debug/TupleDemo.build/TupleDemo-Swift.h -emit-dependencies-path /private/tmp/TupleDemo/.build/arm64-apple-macosx/debug/TupleDemo.build/TupleDemo.emit-module.d -parse-as-library -o /private/tmp/TupleDemo/.build/arm64-apple-macosx/debug/Modules/TupleDemo.swiftmodule -emit-abi-descriptor-path /private/tmp/TupleDemo/.build/arm64-apple-macosx/debug/Modules/TupleDemo.abi.json
1.	Apple Swift version 6.0.3 (swift-6.0.3-RELEASE)
2.	Compiling with the current language version
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for module TupleDemo)
4.	While generating SIL witness table protocol conformance TupleComponent<repeat each T>: Component at 'TupleComponent' (at /private/tmp/TupleDemo/Sources/TupleDemo/TupleDemo.swift:5:8)
5.	While generating protocol witness thunk SIL function "@$s9TupleDemo0A9ComponentVyxxQp_QPGAA0C0A2aEP5writeyy7ContentQzFTW".
 for 'write(_:)' (at /private/tmp/TupleDemo/Sources/TupleDemo/TupleDemo.swift:6:12)
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           0x0000000107db80f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000107db68c4 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000107db8740 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x000000018c18ede4 _sigtramp + 56
4  libsystem_pthread.dylib  0x000000018c157f70 pthread_kill + 288
5  libsystem_c.dylib        0x000000018c064908 abort + 128
6  libsystem_c.dylib        0x000000018c063c1c err + 0
7  swift-frontend           0x0000000107ef6244 (anonymous namespace)::TranslateArguments::expandSingleOuterInnerTuple(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::TupleType>, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::TupleType>, swift::Lowering::ManagedValue) (.cold.35) + 0
8  swift-frontend           0x0000000102fd4b28 (anonymous namespace)::TranslateArguments::expandSingleOuterInnerTuple(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::TupleType>, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::TupleType>, swift::Lowering::ManagedValue) + 1876
9  swift-frontend           0x0000000102fd2680 (anonymous namespace)::ExpanderBase<(anonymous namespace)::TranslateArguments, (anonymous namespace)::ParamInfo>::expand(swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern, swift::CanType) + 616
10 swift-frontend           0x0000000102fd8c24 (anonymous namespace)::TranslateArguments::expandParam(swift::Lowering::AbstractionPattern, swift::AnyFunctionType::CanParam, swift::Lowering::AbstractionPattern, swift::AnyFunctionType::CanParam) + 224
11 swift-frontend           0x0000000102fcbc08 (anonymous namespace)::TranslateArguments::process(swift::Lowering::AbstractionPattern, swift::ArrayRefView<swift::AnyFunctionType::Param, swift::AnyFunctionType::CanParam, swift::AnyFunctionType::CanParam::getFromParam(swift::AnyFunctionType::Param const&), true>, swift::Lowering::AbstractionPattern, swift::ArrayRefView<swift::AnyFunctionType::Param, swift::AnyFunctionType::CanParam, swift::AnyFunctionType::CanParam::getFromParam(swift::AnyFunctionType::Param const&), true>, bool) + 2992
12 swift-frontend           0x0000000102fce160 swift::Lowering::SILGenFunction::emitProtocolWitness(swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILDeclRef, swift::SubstitutionMap, swift::SILDeclRef, swift::SubstitutionMap, swift::Lowering::IsFreeFunctionWitness_t, bool, bool, std::__1::optional<swift::ActorIsolation>) + 2576
13 swift-frontend           0x0000000102ffa7c4 swift::Lowering::SILGenModule::emitProtocolWitness(swift::ProtocolConformanceRef, swift::SILLinkage, swift::SerializedKind_t, swift::SILDeclRef, swift::SILDeclRef, swift::Lowering::IsFreeFunctionWitness_t, swift::Witness) + 2992
14 swift-frontend           0x0000000102ffced0 (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethodImplementation(swift::SILDeclRef, swift::SILDeclRef, swift::Witness) + 528
15 swift-frontend           0x0000000102ffc848 (anonymous namespace)::SILGenWitnessTable<(anonymous namespace)::SILGenConformance>::addMethod(swift::SILDeclRef) + 532
16 swift-frontend           0x0000000102ffc398 swift::SILWitnessVisitor<(anonymous namespace)::SILGenConformance>::visitProtocolDecl(swift::ProtocolDecl*) + 1992
17 swift-frontend           0x0000000102ff9aa4 swift::Lowering::SILGenModule::getWitnessTable(swift::NormalProtocolConformance*) + 324
18 swift-frontend           0x0000000102ffb878 (anonymous namespace)::SILGenType::emitType() + 1580
19 swift-frontend           0x0000000102ffb240 swift::Lowering::SILGenModule::visitNominalTypeDecl(swift::NominalTypeDecl*) + 24
20 swift-frontend           0x0000000102eeb448 swift::ASTLoweringRequest::evaluate(swift::Evaluator&, swift::ASTLoweringDescriptor) const + 880
21 swift-frontend           0x0000000102fe90a4 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&) + 148
22 swift-frontend           0x0000000102ef0d24 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'()) + 340
23 swift-frontend           0x0000000102eeba7c swift::performASTLowering(swift::ModuleDecl*, swift::Lowering::TypeConverter&, swift::SILOptions const&, swift::IRGenOptions const*) + 144
24 swift-frontend           0x00000001028ce358 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1176
25 swift-frontend           0x00000001028d9e5c withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 160
26 swift-frontend           0x00000001028d0028 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 708
27 swift-frontend           0x00000001028cf6fc swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2344
28 swift-frontend           0x00000001026e5edc swift::mainEntry(int, char const**) + 3096
29 dyld                     0x000000018bdd8274 start + 2840

Expected behavior

The OSS toolchain should compile the code without crashing just like the Xcode toolchain does.

Environment

zap /tmp/TupleDemo % ~/Library/Developer/Toolchains/swift-6.0.3-RELEASE.xctoolchain/usr/bin/swift -version
Apple Swift version 6.0.3 (swift-6.0.3-RELEASE)
Target: arm64-apple-macosx15.0

zap /tmp/TupleDemo % /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -version
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

zap /tmp/TupleDemo % sw_vers 
ProductName:		macOS
ProductVersion:		15.3.1
BuildVersion:		24D70

Xcode: Version 16.2 (16C5032a)

Additional information

No response

@marcprux marcprux 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 Mar 9, 2025
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

1 participant