swiftlang / swift

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

Nightly toolchain cannot handle the swift-collections package #74399

Closed glessard closed 3 months ago

glessard commented 3 months ago

Description

The nightly toolchain crashes early when instructed to build the swift-collections package

Reproduction

[/tmp]$ git clone https://github.com/apple/swift-collections
Cloning into 'swift-collections'...
remote: Enumerating objects: 10691, done.
remote: Counting objects: 100% (3627/3627), done.
remote: Compressing objects: 100% (821/821), done.
remote: Total 10691 (delta 2961), reused 3310 (delta 2797), pack-reused 7064
Receiving objects: 100% (10691/10691), 12.96 MiB | 12.16 MiB/s, done.
Resolving deltas: 100% (7800/7800), done.
[/tmp]$ cd swift-collections/
[/tmp/swift-collections]$ xcrun --toolchain org.swift.59202406121a swift build
Segmentation fault: 11

Stack dump

Crashed Thread:        3  Dispatch queue: swift.org.swiftpm.shared.concurrent

Exception Type:        EXC_BAD_ACCESS (SIGSEGV)
Exception Codes:       KERN_INVALID_ADDRESS at 0x0000000000000000
Exception Codes:       0x0000000000000001, 0x0000000000000000

Termination Reason:    Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process:   exc handler [14872]

VM Region Info: 0 is not in any region.  Bytes before following region: 4378624000
      REGION TYPE                    START - END         [ VSIZE] PRT/MAX SHRMOD  REGION DETAIL
      UNUSED SPACE AT START
--->  
      __TEXT                      104fc8000-1066c0000    [ 23.0M] r-x/r-x SM=COW  /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/bin/swift-package

Thread 0::  Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib                 0x1871aa1f4 mach_msg2_trap + 8
1   libsystem_kernel.dylib                 0x1871bcb24 mach_msg2_internal + 80
2   libsystem_kernel.dylib                 0x1871b2e34 mach_msg_overwrite + 476
3   libsystem_kernel.dylib                 0x1871aa578 mach_msg + 24
4   CoreFoundation                         0x1872ca680 __CFRunLoopServiceMachPort + 160
5   CoreFoundation                         0x1872c8f44 __CFRunLoopRun + 1208
6   CoreFoundation                         0x1872c8434 CFRunLoopRunSpecific + 608
7   CoreFoundation                         0x18734645c CFRunLoopRun + 64
8   libswift_Concurrency.dylib             0x24f7684e0 swift_task_asyncMainDrainQueueImpl() + 40
9   libswift_Concurrency.dylib             0x24f7684a0 swift_task_asyncMainDrainQueue + 92
10  swift-package                          0x104fcd610 main + 84
11  dyld                                   0x186e620e0 start + 2360

Thread 1:
0   libsystem_kernel.dylib                 0x1871ad9ec __psynch_cvwait + 8
1   libsystem_pthread.dylib                0x1871eb55c _pthread_cond_wait + 1228
2   swift-package                          0x105457810 closure #2 in tsc_await<A>(_:) + 196
3   swift-package                          0x105457450 tsc_await<A>(_:) + 280
4   swift-package                          0x105457940 tsc_await<A, B>(_:) + 188
5   swift-package                          0x105457310 tsc_await<A, B>(_:) + 20
6   swift-package                          0x105d8d230 SwiftCommandState.getRootPackageInformation() + 176
7   swift-package                          0x105d61208 NativeBuildSystemFactory.makeBuildSystem(explicitProduct:cacheBuildManifest:productsBuildParameters:toolsBuildParameters:packageGraphLoader:outputStream:logLevel:observabilityScope:) + 76
8   swift-package                          0x105d61a24 protocol witness for BuildSystemFactory.makeBuildSystem(explicitProduct:cacheBuildManifest:productsBuildParameters:toolsBuildParameters:packageGraphLoader:outputStream:logLevel:observabilityScope:) in conformance NativeBuildSystemFactory + 44
9   swift-package                          0x1061b3664 BuildSystemProvider.createBuildSystem(kind:explicitProduct:cacheBuildManifest:productsBuildParameters:toolsBuildParameters:packageGraphLoader:outputStream:logLevel:observabilityScope:) + 256
10  swift-package                          0x105d931f0 SwiftCommandState.createBuildSystem(explicitBuildSystem:explicitProduct:cacheBuildManifest:shouldLinkStaticSwiftStdlib:productsBuildParameters:toolsBuildParameters:packageGraphLoader:outputStream:logLevel:observabilityScope:) + 752
11  swift-package                          0x105d00668 SwiftBuildCommand.build(_:subset:productsBuildParameters:toolsBuildParameters:) + 512
12  swift-package                          0x105cffe98 SwiftBuildCommand.run(_:) + 2316
13  swift-package                          0x105d00f3d protocol witness for AsyncSwiftCommand.run(_:) in conformance SwiftBuildCommand + 1
14  swift-package                          0x105d8f7b5 AsyncSwiftCommand.run() + 1
15  swift-package                          0x105d05bbd protocol witness for AsyncParsableCommand.run() in conformance SwiftBuildCommand + 1
16  swift-package                          0x104fe9639 static AsyncParsableCommand.main() + 1
17  swift-package                          0x104fcde99 specialized static SwiftPM.main(execName:) + 1
18  swift-package                          0x104fce299 specialized static SwiftPM.main() + 1
19  swift-package                          0x104fcd685 specialized thunk for @escaping @convention(thin) @async () -> () + 1
20  libswift_Concurrency.dylib             0x24f769149 completeTaskAndRelease(swift::AsyncContext*, swift::SwiftError*) + 1

Thread 2::  Dispatch queue: swift.org.swiftpm.shared.concurrent
0   libsystem_kernel.dylib                 0x1871b87cc fstatat + 8
1   libsystem_c.dylib                      0x1870925a4 fts_stat2 + 324
2   libsystem_c.dylib                      0x187092200 __fts_open + 308
3   libremovefile.dylib                    0x193e56608 __removefile_tree_walker + 92
4   libremovefile.dylib                    0x193e56520 removefile + 340
5   Foundation                             0x1883f6d7c -[NSFilesystemItemRemoveOperation main] + 296
6   Foundation                             0x1883df9dc __NSOPERATION_IS_INVOKING_MAIN__ + 16
7   Foundation                             0x1883ded84 -[NSOperation start] + 648
8   Foundation                             0x1883f6c1c -[NSFileManager removeItemAtPath:error:] + 48
9   swift-package                          0x1054a3370 closure #2 in withTemporaryDirectory<A>(dir:prefix:_:) + 140
10  swift-package                          0x105bd884c partial apply for closure #1 in closure #1 in withTemporaryDirectory<A>(dir:prefix:_:) + 20
11  swift-package                          0x105f9757c closure #1 in closure #2 in closure #5 in ManifestLoader.evaluateManifest(at:vfsOverlayPath:packageIdentity:packageLocation:toolsVersion:observabilityScope:delegate:delegateQueue:callbackQueue:completion:) + 2136
12  swift-package                          0x105fa0a88 partial apply for closure #1 in closure #2 in closure #5 in ManifestLoader.evaluateManifest(at:vfsOverlayPath:packageIdentity:packageLocation:toolsVersion:observabilityScope:delegate:delegateQueue:callbackQueue:completion:) + 140
13  swift-package                          0x1054918e0 Process.waitUntilExit(_:) + 872
14  swift-package                          0x10549a838 partial apply for closure #2 in Process.waitUntilExit(_:) + 28
15  swift-package                          0x105491e68 thunk for @escaping @callee_guaranteed @Sendable () -> () + 28
16  libdispatch.dylib                      0x187038750 _dispatch_call_block_and_release + 32
17  libdispatch.dylib                      0x18703a3e8 _dispatch_client_callout + 20
18  libdispatch.dylib                      0x18703d8ec _dispatch_continuation_pop + 600
19  libdispatch.dylib                      0x18703cf08 _dispatch_async_redirect_invoke + 584
20  libdispatch.dylib                      0x18704bea8 _dispatch_root_queue_drain + 392
21  libdispatch.dylib                      0x18704c6b8 _dispatch_worker_thread2 + 156
22  libsystem_pthread.dylib                0x1871e6fd0 _pthread_wqthread + 228
23  libsystem_pthread.dylib                0x1871e5d28 start_wqthread + 8

Thread 3 Crashed::  Dispatch queue: swift.org.swiftpm.shared.concurrent
0   ???                                            0x0 ???
1   swift-package                          0x105f9da14 partial apply for closure #3 in ManifestLoader.load(manifestPath:manifestToolsVersion:packageIdentity:packageKind:packageLocation:packageVersion:identityResolver:dependencyMapper:fileSystem:observabilityScope:delegateQueue:callbackQueue:completion:) + 144
2   swift-package                          0x105fa12ac partial apply for closure #1 in closure #1 in ManifestLoader.loadAndCacheManifest(at:toolsVersion:packageIdentity:packageKind:packageLocation:packageVersion:identityResolver:dependencyMapper:fileSystem:observabilityScope:delegate:delegateQueue:callbackQueue:completion:) + 28
3   swift-package                          0x105f8ff0c thunk for @escaping @callee_guaranteed @Sendable () -> () + 28
4   libdispatch.dylib                      0x187038750 _dispatch_call_block_and_release + 32
5   libdispatch.dylib                      0x18703a3e8 _dispatch_client_callout + 20
6   libdispatch.dylib                      0x18703d8ec _dispatch_continuation_pop + 600
7   libdispatch.dylib                      0x18703cf08 _dispatch_async_redirect_invoke + 584
8   libdispatch.dylib                      0x18704bea8 _dispatch_root_queue_drain + 392
9   libdispatch.dylib                      0x18704c6b8 _dispatch_worker_thread2 + 156
10  libsystem_pthread.dylib                0x1871e6fd0 _pthread_wqthread + 228
11  libsystem_pthread.dylib                0x1871e5d28 start_wqthread + 8

Thread 4:
0   libsystem_pthread.dylib                0x1871e5d20 start_wqthread + 0

Thread 3 crashed with ARM Thread State (64-bit):
    x0: 0x000000016af4a998   x1: 0x000000015a02a628   x2: 0x00000001f0f73a60   x3: 0x000000016af49658
    x4: 0x000000016af49910   x5: 0x000000016af498f0   x6: 0x0000000000000000   x7: 0x0000000000000000
    x8: 0x0000000000000000   x9: 0x000000015a02a628  x10: 0x000000016af49660  x11: 0x00000001973f07a4
   x12: 0x00000001973f07a4  x13: 0x000060000249a520  x14: 0x01000001ef08ba19  x15: 0x00000001ef08ba18
   x16: 0x0000000000000000  x17: 0xe0810001f0f86608  x18: 0x0000000000000000  x19: 0x000000016af4a7c0
   x20: 0x0000000000000001  x21: 0x00000001062b6c80  x22: 0x00000001f551a208  x23: 0x0000600001f9d200
   x24: 0x000060000068ce70  x25: 0x0000600001584960  x26: 0xf00000000000002c  x27: 0x0000000149f040f8
   x28: 0x000060000068cff0   fp: 0x000000016af4ad40   lr: 0x0000000105f91808
    sp: 0x000000016af4a7b0   pc: 0x0000000000000000 cpsr: 0x60001000
   far: 0x0000000000000000  esr: 0x82000006 (Instruction Abort) Translation fault

Binary Images:
       0x128e34000 -        0x1316fffff lib_InternalSwiftScan.dylib (*) <05d9bd70-9391-38f4-9307-28a133769fe4> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/lib/swift/host/lib_InternalSwiftScan.dylib
       0x10873c000 -        0x108783fff libSwiftCompilerPluginMessageHandling.dylib (*) <24ba92ec-8bd7-358b-ade1-61ce069f01f4> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/lib/swift/host/libSwiftCompilerPluginMessageHandling.dylib
       0x10869c000 -        0x1086dbfff libSwiftSyntaxMacroExpansion.dylib (*) <3ee3c79c-c9fa-3317-af6a-35b54451b346> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/lib/swift/host/libSwiftSyntaxMacroExpansion.dylib
       0x108634000 -        0x10865bfff libSwiftOperators.dylib (*) <7002b7a7-dde3-3b77-bf8c-fd47a13025c0> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/lib/swift/host/libSwiftOperators.dylib
       0x1085e4000 -        0x1085f3fff libSwiftSyntaxMacros.dylib (*) <c1becbab-2c51-3c1e-95b3-f2b2e43453b2> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/lib/swift/host/libSwiftSyntaxMacros.dylib
       0x108b64000 -        0x108bbbfff libSwiftSyntaxBuilder.dylib (*) <70a15b96-a29c-350b-b2d8-e42e076fdf03> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/lib/swift/host/libSwiftSyntaxBuilder.dylib
       0x10892c000 -        0x1089affff libSwiftParserDiagnostics.dylib (*) <e4c01eb0-17a3-30e5-926f-8aaa6f9e3f67> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/lib/swift/host/libSwiftParserDiagnostics.dylib
       0x10857c000 -        0x108597fff libSwiftBasicFormat.dylib (*) <7b3229ad-9a51-3046-8975-51f6a076d568> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/lib/swift/host/libSwiftBasicFormat.dylib
       0x10881c000 -        0x10883bfff libSwiftIDEUtils.dylib (*) <3944a7c4-b6fe-33b5-9fe2-55e989c270ca> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/lib/swift/host/libSwiftIDEUtils.dylib
       0x109260000 -        0x1093abfff libSwiftParser.dylib (*) <e8ac1a3b-f676-3ff5-9e18-06a6bfb001e3> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/lib/swift/host/libSwiftParser.dylib
       0x108af8000 -        0x108b13fff libSwiftDiagnostics.dylib (*) <16d827f4-2c4f-3ac5-9507-fa39b772a371> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/lib/swift/host/libSwiftDiagnostics.dylib
       0x10aeb0000 -        0x10b27bfff libSwiftSyntax.dylib (*) <dc3bfc62-ff23-36b8-a99b-82e7208d9979> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/lib/swift/host/libSwiftSyntax.dylib
       0x104fc8000 -        0x1066bffff swift-package (*) <1c0e8fa2-bf6b-3692-ba7c-da5b7ba3c3c1> /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-06-12-a.xctoolchain/usr/bin/swift-package
       0x1871a9000 -        0x1871e3ffb libsystem_kernel.dylib (*) <9b8b53f9-e2b6-36df-98e9-28d8fca732f2> /usr/lib/system/libsystem_kernel.dylib
       0x18724c000 -        0x187724fff com.apple.CoreFoundation (6.9) <84b539d5-22c9-3f8c-84c8-903e9c7b8d29> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
       0x24f713000 -        0x24f77eff7 libswift_Concurrency.dylib (*) <ecc0aae8-fbf0-31df-9881-88fba5de2fa3> /usr/lib/swift/libswift_Concurrency.dylib
       0x186e5c000 -        0x186ee4a17 dyld (*) <37bbc384-0755-31c7-a808-0ed49e44dd8e> /usr/lib/dyld
               0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
       0x1871e4000 -        0x1871f0fff libsystem_pthread.dylib (*) <386b0fc1-7873-3328-8e71-43269fd1b2c7> /usr/lib/system/libsystem_pthread.dylib
       0x196eb4000 -        0x197411fff libswiftCore.dylib (*) <c2fd0f69-d72c-37a5-938e-1bd710c88431> /usr/lib/swift/libswiftCore.dylib
       0x187081000 -        0x1870ffff7 libsystem_c.dylib (*) <05b44e93-dffc-3bd8-90ab-fd97cb73f171> /usr/lib/system/libsystem_c.dylib
       0x193e55000 -        0x193e57ffb libremovefile.dylib (*) <a66b11d1-ebc0-36a0-98b1-27f13ce7f240> /usr/lib/system/libremovefile.dylib
       0x1883a1000 -        0x188ffefff com.apple.Foundation (6.9) <99e0292d-7873-3968-9c9c-5955638689a5> /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
       0x187036000 -        0x18707dfff libdispatch.dylib (*) <502762ee-7aa7-306c-9dbd-88981a86bb78> /usr/lib/system/libdispatch.dylib

Expected behavior

It should build the package, or emit a legitimate error while trying.

Environment

$ xcrun --toolchain org.swift.59202406121a swift --version
Apple Swift version 6.0-dev (LLVM 57177aa1b91540b, Swift 3889ede01784b87)
Target: arm64-apple-macosx14.0

macOS 14.5, with Xcode 15 beta 1 (16A5171c).

Additional information

Copied to rdar://129787471

glessard commented 3 months ago

Added the Xcode label, because this doesn't happen with Xcode 14.5. This seems due to Xcode 15b1.

airspeedswift commented 3 months ago

@glessard can you include the stack trace for the failure?

glessard commented 3 months ago

Updated above. I forgot to specify that this was on macOS 14.5 (23F79).

MaxDesiatov commented 3 months ago

Seems to be a duplicate of https://github.com/swiftlang/swift/issues/73327.