Open weissi opened 1 week ago
Apple folks, rdar://139710145
One line repro
docker run -it --rm swift:6.0-noble bash -c 'mkdir /tmp/foo && cd /tmp/foo && swift package init && echo -e "import XCTest; final class MyTests: XCTestCase { func test_foo1() throws {}; func test_foo2() throws {}; func test_foo3() {}; func test_foo4() {}; func test_foo5() {}; func test_foo6() {}; func test_foo7() {}; func test_foo8() {} }" > Tests/fooTests/fooTests.swift && while swift test; do date; done'
output
$ docker run -it --rm swift:6.0-noble bash -c 'mkdir /tmp/foo && cd /tmp/foo && swift package init && echo -e "import XCTest; final class MyTests: XCTestCase { func test_foo1() throws {}; func test_foo2() throws {}; func test_foo3() {}; func test_foo4() {}; func test_foo5() {}; func test_foo6() {}; func test_foo7() {}; func test_foo8() {} }" > Tests/fooTests/fooTests.swift && while swift test; do date; done'
Creating library package: foo
Creating Package.swift
Creating .gitignore
Creating Sources/
Creating Sources/foo/foo.swift
Creating Tests/
Creating Tests/fooTests/
Creating Tests/fooTests/fooTests.swift
Building for debugging...
[26/26] Linking fooPackageTests.xctest
Build complete! (4.49s)
Test Suite 'All tests' started at 2024-11-12 11:30:24.051
Test Suite 'debug.xctest' started at 2024-11-12 11:30:24.052
Test Suite 'MyTests' started at 2024-11-12 11:30:24.052
Test Case 'MyTests.test_foo1' started at 2024-11-12 11:30:24.052
Test Case 'MyTests.test_foo1' passed (0.0 seconds)
Test Case 'MyTests.test_foo2' started at 2024-11-12 11:30:24.052
[... hang forever ...]
I'm reproing this in Docker for Mac, native architecture, both Intel and Apple Silicon.
Higher chance of repro:
docker run -it --rm swift:6.0-noble bash -c 'mkdir /tmp/foo && cd /tmp/foo && swift package init && echo -e "import XCTest; final class MyTests: XCTestCase { func test_foo1() throws {}; func test_foo2() throws {} }" > Tests/fooTests/fooTests.swift && swift test && while .build/debug/fooPackageTests.xctest; do date; done'
This reproduces from Swift 5.6 on, Swift 5.5 and older are okay.
kernel versions:
Linux 3cd2665b1108 6.10.4-linuxkit #1 SMP PREEMPT_DYNAMIC Wed Oct 2 16:39:54 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
and
Linux e7c7d1145331 6.10.4-linuxkit #1 SMP Mon Aug 12 08:47:01 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux
In both Swift 5.10 & Swift 6.0 on Linux, there's a trivial deadlock in XCTest itself.
Repro
swift package init
Tests/*Tests/*Tests.swift
while swift test; do date; done
Expected
Runs the tests forever
Actual
Versions
Extra info
The main thread is blocked
ppoll
waiting.