Open
Description
Description
When running our suite of unit tests on Swift 6.2.dev (swiftlang/swift:nightly-main-jammy), our code triggers an assertion which is not triggered on Swift 6.0 or Swift 6.1
description of the issue :
swift-server/swift-aws-lambda-runtime#509
Cause :
The crash is caused by Concurrency.assumeIsolated
here
https://github.com/swift-server/swift-aws-lambda-runtime/blob/7322a3694ae8e025b3b4[…]89ad53d0d2f2/Sources/AWSLambdaRuntime/LambdaRuntimeClient.swift
channel.closeFuture.whenComplete { result in
self.assumeIsolated { runtimeClient in
runtimeClient.channelClosed(channel)
}
}
Reproduction
git clone https://github.com/swift-server/swift-aws-lambda-runtime.git
cd swift-aws-lambda-runtime
docker run -it --rm -v .:/work swiftlang/swift:nightly-main-jammy bash -c "cd work && swift test"
Stack dump
AWSLambdaRuntime/LambdaRuntimeClient.swift:339: Fatal error: Incorrect actor executor assumption; Expected same executor as AWSLambdaRuntime.LambdaRuntimeClient.
2025-03-19T09:41:13+0000 info MockLambdaServer : [AWSLambdaRuntimeTests] AWSLambdaRuntimeTests.HTTPHandler processing /2018-06-01/runtime/invocation/next
*** Signal 5: Backtracing from 0xffffa6aa7970... done ***
*** Program crashed: System trap at 0x0000ffffa6aa7970 ***
Platform: arm64 Linux (Ubuntu 22.04.5 LTS)
Thread 0 "NIO-SGLTN-0-#3" crashed:
0 0x0000ffffa6aa7970 _assertionFailure(_:_:file:line:flags:) + 164 in libswiftCore.so
1 [ra] [system] 0x0000aaaac62a1ee0 Actor.assumeIsolated<A>(_:file:line:) + 331 in swift-aws-lambda-runtimePackageTests.xctest at //<compiler-generated>
2 [ra] 0x0000aaaac62a1c94 closure #3 in LambdaRuntimeClient.makeOrGetConnection() + 227 in swift-aws-lambda-runtimePackageTests.xctest at /work/Sources/AWSLambdaRuntime/LambdaRuntimeClient.swift:339:22
3 [ra] 0x0000aaaac65c8f54 closure #1 in EventLoopFuture.whenComplete(_:) + 435 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOCore/EventLoopFuture.swift:872:13
4 [ra] 0x0000aaaac65d2fd0 CallbackList._run() + 343 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOCore/EventLoopFuture.swift:92:27
5 [ra] 0x0000aaaac65d38b0 EventLoopPromise._resolve<A>(value:) + 275 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOCore/EventLoopFuture.swift:263:42
6 [ra] 0x0000aaaac65d3780 EventLoopPromise.succeed(_:) + 179 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOCore/EventLoopFuture.swift:197:14
7 [ra] 0x0000aaaac67288e4 closure #3 in BaseSocketChannel.close0(error:mode:promise:) + 163 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOPosix/BaseSocketChannel.swift:914:31
8 [ra] 0x0000aaaac67d282c closure #1 in SelectableEventLoop.run(_:) + 155 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:590:17
9 [ra] [thunk] 0x0000aaaac67d6744 partial apply for closure #1 in SelectableEventLoop.run(_:) + 27 in swift-aws-lambda-runtimePackageTests.xctest at //<compiler-generated>
10 [ra] 0x0000aaaac67da04c withAutoReleasePool<A>(_:) + 47 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:46:16
11 [ra] 0x0000aaaac67dd674 SelectableEventLoop.run(_:) + 107 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:587:9
12 [ra] 0x0000aaaac67de4d8 SelectableEventLoop.runLoop(selfIdentifier:) + 899 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:764:22
13 [ra] 0x0000aaaac67de8f4 SelectableEventLoop.run() + 615 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOPosix/SelectableEventLoop.swift:877:33
14 [ra] 0x0000aaaac67863b4 static MultiThreadedEventLoopGroup.runTheLoop(thread:parentGroup:canEventLoopBeShutdownIndividually:selectorFactory:initializer:metricsDelegate:_:) + 655 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:105:22
15 [ra] 0x0000aaaac67801e4 closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:parentGroup:selectorFactory:initializer:metricsDelegate:) + 283 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOPosix/MultiThreadedEventLoopGroup.swift:126:41
16 [ra] [thunk] 0x0000aaaac6782c38 partial apply for closure #1 in static MultiThreadedEventLoopGroup.setupThreadAndEventLoop(name:parentGroup:selectorFactory:initializer:metricsDelegate:) + 55 in swift-aws-lambda-runtimePackageTests.xctest at //<compiler-generated>
17 [ra] [thunk] 0x0000aaaac680d330 thunk for @escaping @callee_guaranteed (@guaranteed NIOThread) -> () + 23 in swift-aws-lambda-runtimePackageTests.xctest at //<compiler-generated>
18 [ra] 0x0000aaaac680fa5c closure #1 in closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) + 767 in swift-aws-lambda-runtimePackageTests.xctest at /work/.build/checkouts/swift-nio/Sources/NIOPosix/ThreadPosix.swift:153:21
19 [ra] [thunk] 0x0000aaaac680fb0c @objc closure #1 in closure #1 in static ThreadOpsPosix.run(handle:args:detachThread:) + 11 in swift-aws-lambda-runtimePackageTests.xctest at //<compiler-generated>
20 [ra] 0x0000ffffa53bd5b8 <unknown> in libc.so.6
...
Registers:
x0 0x0000000200000003 8589934595
x1 0x0000000000000003 3
x2 0x0000ffff480097e8 03 00 00 00 00 00 00 00 a0 00 00 00 00 00 00 80 ········ ·······
x3 0x0000ffff480008e0 07 00 06 00 06 00 07 00 05 00 07 00 02 00 02 00 ················
x4 0x000000000000000c 12
x5 0x0000ffff480070e0 37 a1 f4 b7 f0 ff 00 00 c2 3b 85 96 d3 94 38 9d 7¡ô·ðÿ··Â;··Ó·8·
x6 0x9d3894d396853bc2 11328968499134806978
x7 0x636e49203a726f72 7164744459961397106
x8 0x0000000000000000 0
x9 0x74706d7573736120 8390326457006776608
x10 0x746e75526164626d 8389772152519549549
x11 0x626d614c2e656d69 7092431968002207081
x12 0x6d69746e75526164 7883960640452321636
x13 0x2e746e65696c4365 3347421804882576229
x14 0x707845203b6e6f69 8104303534191570793
x15 0x6173206465746365 7021991859571680101
x16 0x0000000000000001 1
x17 0x0000ffffa53cdbc4 40 07 00 b4 fd 7b bc a9 01 40 00 d1 fd 03 00 91 @··´ý{¼©·@·Ñý···
x18 0x0000000000000000 0
x19 0x0000ffff8cc0deb0 18 00 00 00 ff ff ff ff 10 e0 c0 8c ff ff 00 00 ····ÿÿÿÿ·àÀ·ÿÿ··
x20 0x0000ffff8cc0d610 64 00 00 00 00 00 00 f0 e0 97 00 48 ff ff 00 00 d······ðà··Hÿÿ··
x21 0x0000000000000000 0
x22 0x000000000080e860 8448096
x23 0x0000ffff9a00d68f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ················
x24 0x0000000000000000 0
x25 0x0000ffff8c400000 281473034747904
x26 0x000000000080e860 8448096
x27 0x0000ffff9a00f020 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ················
x28 0x0000ffff8c400000 281473034747904
fp 0x0000ffff8cc0d510 30 d6 c0 8c ff ff 00 00 e0 1e 2a c6 aa aa 00 00 0ÖÀ·ÿÿ··à·*ƪª··
lr 0x0000ffffa6aa7970 20 00 20 d4 28 00 80 52 89 12 80 52 60 16 00 d0 · Ô(··R···R`··Ð
sp 0x0000ffff8cc0d4a0 01 00 00 00 ff ff 00 00 24 00 00 00 00 00 00 00 ····ÿÿ··$·······
pc 0x0000ffffa6aa7970 20 00 20 d4 28 00 80 52 89 12 80 52 60 16 00 d0 · Ô(··R···R`··Ð
Images (20 omitted):
0x0000aaaac61d0000–0x0000aaaac7443130 d6271c9a9ce41191a18fcbbcebca1415a5698657 swift-aws-lambda-runtimePackageTests.xctest /work/.build/aarch64-unknown-linux-gnu/debug/swift-aws-lambda-runtimePackageTests.xctest
0x0000ffffa5340000–0x0000ffffa54c73fc 2a450fe74d1b79a321cc1b12337fc31a2c3fb834 libc.so.6 /usr/lib/aarch64-linux-gnu/libc.so.6
0x0000ffffa6800000–0x0000ffffa6d35df0 313826d2bd961f2001612a2cf247a9c12150f0df libswiftCore.so /usr/lib/swift/linux/libswiftCore.so
Backtrace took 0.25s
Expected behavior
no crash :-)
Or consistent crash on 6.0 and 6.1
Environment
Swift version 6.2-dev (LLVM 162ee50b401fff2, Swift 57288d1)
Target: aarch64-unknown-linux-gnu
Build config: +assertions
Additional information
This crash happens both on macOS and Linux
I can not reproduce this on 6.0.x or 6.1