swiftlang/swift-package-manager

swift sdk install crashes in URLSessionHTTPClient.execute and Archiver.extract when built with Swift 6.0

vsarunas opened this issue · 11 comments

Is it reproducible with SwiftPM command-line tools: swift build, swift test, swift package etc?

  • Confirmed reproduction steps with SwiftPM CLI.

Description

Hello,

I'm following steps on https://www.swift.org/documentation/articles/static-linux-getting-started.html for doing cross compile to Linux and failing to install SDK. Unfortunately it turns out that swift sdk that is shipped with latest 6.0 release toolchain is completely not working.

This is also reproducible if building SPM from source locally; yet it works fine if it is built with swift 5.10.

Expected behavior

No response

Actual behavior

swift-package crash on install

Steps to reproduce

  1. export PATH=$HOME/Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-08-a.xctoolchain/usr/bin:$PATH
  2. swift sdk install https://download.swift.org/development/static-sdk/swift-DEVELOPMENT-SNAPSHOT-2024-06-06-a/swift-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.tar.gz

This leads to a crash:

Thread 4 Crashed:
0   swift-package                 	       0x102c603a0 URLSessionHTTPClient.execute@Sendable (_:progress:) + 92
1   swift-package                 	       0x102c4752d implicit closure #3 in implicit closure #2 in implicit closure #1 in HTTPClient.init(configuration:implementation:) + 1
2   swift-package                 	       0x102c4af19 partial apply for implicit closure #3 in implicit closure #2 in implicit closure #1 in HTTPClient.init(configuration:implementation:) + 1
3   swift-package                 	       0x102c4742d $s6Basics17HTTPClientRequestVs5Int64VAESgs5Error_pIeghyyzo_SgAA0B8ResponseVsAG_pIeghHngozo_ACxq_q0_sAG_pRi_zRi0_zRi__Ri0__Ri_0_Ri0_0_r1_lyAeFytIseghnnrzo_SgAJsAG_pIeghHnnrzo_TRTQ0_ + 1
4   swift-package                 	       0x102c4b161 $s6Basics17HTTPClientRequestVs5Int64VAESgs5Error_pIeghyyzo_SgAA0B8ResponseVsAG_pIeghHngozo_ACxq_q0_sAG_pRi_zRi0_zRi__Ri0__Ri_0_Ri0_0_r1_lyAeFytIseghnnrzo_SgAJsAG_pIeghHnnrzo_TRTATQ0_ + 1
5   swift-package                 	       0x102c47671 $s6Basics17HTTPClientRequestVxq_q0_s5Error_pRi_zRi0_zRi__Ri0__Ri_0_Ri0_0_r1_lys5Int64VAFSgytIseghnnrzo_SgAA0B8ResponseVsAD_pIeghHnnrzo_AcfGsAD_pIeghyyzo_SgAJsAD_pIeghHngozo_TRTQ0_ + 1
6   swift-package                 	       0x102c4b165 $s6Basics17HTTPClientRequestVxq_q0_s5Error_pRi_zRi0_zRi__Ri0__Ri_0_Ri0_0_r1_lys5Int64VAFSgytIseghnnrzo_SgAA0B8ResponseVsAD_pIeghHnnrzo_AcfGsAD_pIeghyyzo_SgAJsAD_pIeghHngozo_TRTATQ0_ + 1
7   swift-package                 	       0x102c483b5 HTTPClient.executeWithStrategies(request:requestNumber:_:_:) + 1
8   swift-package                 	       0x102c47e81 HTTPClient.execute(_:observabilityScope:progress:) + 1
9   swift-package                 	       0x1030f8931 closure #1 in SwiftSDKBundleStore.install(bundlePathOrURL:_:_:) + 1
10  swift-package                 	       0x1030fad95 partial apply for closure #1 in SwiftSDKBundleStore.install(bundlePathOrURL:_:_:) + 1

Same happens if using via Xcode:

xcrun --toolchain swift swift --version 
Apple Swift version 6.0-dev (LLVM bf8bbb910874156, Swift 2a6163f0e50d955)
Target: arm64-apple-macosx14.0
xcrun --toolchain swift swift sdk list
No Swift SDKs are currently installed.
 xcrun --toolchain swift swift sdk install https://download.swift.org/swift-6.0-branch/static-sdk/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.tar.gz
Downloading a Swift SDK bundle archive from `https://download.swift.org/swift-6.0-branch/static-sdk/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.tar.gz`...
[1]    76615 segmentation fault  xcrun --toolchain swift swift sdk install 

Local archive is not successful as well:

xcrun --toolchain swift swift sdk install  $HOME/Downloads/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.tar.gz
Swift SDK bundle at `/Users/sarunas/Downloads/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.tar.gz` is assumed to be an archive, unpacking...
[1]    77577 segmentation fault  xcrun --toolchain swift swift sdk install 

Here the crash happens in:

Thread 3 Crashed:
0   swift-package                 	       0x100e13708 Archiver.extract(from:to:) + 104
1   swift-package                 	       0x1012f9859 SwiftSDKBundleStore.unpackIfNeeded(bundlePathOrURL:validatedBundlePath:temporaryDirectory:_:) + 1
2   swift-package                 	       0x1012f8fd5 SwiftSDKBundleStore.installIfValid(bundlePathOrURL:validatedBundlePath:temporaryDirectory:archiver:) + 1
3   swift-package                 	       0x1012f8b51 closure #1 in SwiftSDKBundleStore.install(bundlePathOrURL:_:_:) + 1
4   swift-package                 	       0x1012fad95 partial apply for closure #1 in SwiftSDKBundleStore.install(bundlePathOrURL:_:_:) + 1
5   swift-package                 	       0x100e40341 closure #1 in withTemporaryDirectory<A>(fileSystem:dir:prefix:removeTreeOnDeinit:_:) + 1
6   swift-package                 	       0x100e40515 partial apply for closure #1 in withTemporaryDirectory<A>(fileSystem:dir:prefix:removeTreeOnDeinit:_:) + 1
7   swift-package                 	       0x100e3fd49 closure #1 in closure #1 in withTemporaryDirectory<A>(fileSystem:dir:prefix:_:) + 1
8   swift-package                 	       0x100e40979 partial apply for closure #1 in closure #1 in withTemporaryDirectory<A>(fileSystem:dir:prefix:_:) + 1
9   libswift_Concurrency.dylib    	       0x265eab7f1 withTaskCancellationHandler<A>(operation:onCancel:) + 1

Same happens on locally built Swift 6 in release mode:

➜  swift-package-manager git:(release/6.0) ./.build/release/swift-sdk install  $HOME/Downloads/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.tar.gz
Swift SDK bundle at `/Users/sarunas/Downloads/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.tar.gz` is assumed to be an archive, unpacking...
[1]    97485 segmentation fault  ./.build/release/swift-sdk install 

Crash this time shows:

Thread 1 Crashed:
0   swift-sdk                     	       0x100d5d0c4 specialized withCheckedThrowingContinuation<A>(isolation:function:_:) + 28 [inlined]
1   swift-sdk                     	       0x100d5d0c4 Archiver.extract(from:to:) + 104 (Archiver.swift:68)
2   swift-sdk                     	       0x101171f3d SwiftSDKBundleStore.unpackIfNeeded(bundlePathOrURL:validatedBundlePath:temporaryDirectory:_:) + 1 (SwiftSDKBundleStore.swift:241)
3   swift-sdk                     	       0x1011716b9 SwiftSDKBundleStore.installIfValid(bundlePathOrURL:validatedBundlePath:temporaryDirectory:archiver:) + 1 (SwiftSDKBundleStore.swift:277)
4   swift-sdk                     	       0x101171235 closure #1 in SwiftSDKBundleStore.install(bundlePathOrURL:_:_:) + 1 (SwiftSDKBundleStore.swift:208)
5   swift-sdk                     	       0x101173479 partial apply for closure #1 in SwiftSDKBundleStore.install(bundlePathOrURL:_:_:) + 1

yet; if switching to swift 5.10 able to install SDK:

➜  swift-package-manager git:(release/6.0) swift --version                                                                                                                         
swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

➜  swift-package-manager git:(release/6.0) swift build -c release

➜  swift-package-manager git:(release/6.0) ./.build/release/swift-sdk install  $HOME/Downloads/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.tar.gz
Swift SDK bundle at `/Users/sarunas/Downloads/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.tar.gz` is assumed to be an archive, unpacking...
Swift SDK bundle at `/Users/sarunas/Downloads/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.tar.gz` successfully installed as swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.

Swift Package Manager version/commit hash

9afe748

Swift & OS version (output of swift --version ; uname -a)

$ swift --version
Apple Swift version 6.0-dev (LLVM bf8bbb910874156, Swift a0bb875256e41ae)
Target: arm64-apple-macosx14.0
$ uname -a
Darwin alpine.local 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64

See also FB13850220, rdar://129627584

I believe the swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a toolchain works — at least, it did when I wrote the Getting Started with the Static Linux SDK document. I'm running a local build at the moment to see if I can reproduce it and figure out what's going wrong with SwiftPM.

Yesterday's toolchain is bad as well for me:

wget https://download.swift.org/swift-6.0-branch/xcode/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-11-a/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-11-a-osx.pkg
open swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-11-a-osx.pkg # install for user
export PATH=$HOME/Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-11-a.xctoolchain/usr/bin:$PATH

swift --version
Apple Swift version 6.0-dev (LLVM 3bba20e27a3bcf9, Swift 8e8e486fb05209f)
Target: arm64-apple-macosx14.0

swift sdk  --version
[1]    48663 segmentation fault  swift sdk --version

swift sdk install
[1]    49320 segmentation fault  swift sdk install

swift sdk install  $HOME/Downloads/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.tar.gz        
Swift SDK bundle at `/Users/sarunas/Downloads/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-06-06-a_static-linux-0.0.1.artifactbundle.tar.gz` is assumed to be an archive, unpacking...
[1]    49618 segmentation fault  swift sdk install 

This doesn't reproduce for me here, but we'll keep looking at it and try to figure out what's going wrong.

What host OS are you running? This could be the @available 9999 issue

Stock Sonoma 14.5 on M1 Max.

 sw_vers 
ProductName:		macOS
ProductVersion:		14.5
BuildVersion:		23F79

Im having trouble finding the GitHub issue at the moment, but this seems like the exact problem I'm thinking of. Basically some versions of macOS don't play nice with the 6.0 toolchain.

cc @kubamracek always remembers these details which I forget

I'll try out tomorrow in a VM Sequoia; but just tried building SPM release/6.0 within Xcode 15.4 and 6.0 toolchain from yesterday and it was able to import the toolchain fine... Mystery.

@rauhul Is this what you are looking for? swiftlang/swift#73327

@kkebo Yes!

Thanks! Closing this as duplicate then for swiftlang/swift#73327