Skip to content

Commit c2028b5

Browse files
committed
Revert "Generated code for XCTest on non-Darwin needs to be actor-isolated. (#7566)"
This reverts commit 092f80d. Amazon Linux 2 has been crashing (see below) in almost every test run since this change. It appears the crash existed before it, it's just *much* more consistent now. Not clear if this is the backtrace every time, it's almost always just `getrn`, but we have seen this once: ``` 0 0x0000ffffa4e4b948 getrn + 136 in libcrypto.so.1.0.2k 1 [ra] 0x0000ffffa4e4bddc lh_delete + 55 in libcrypto.so.1.0.2k 2 [ra] 0x0000ffffa4e4eaac int_thread_del_item + 123 in libcrypto.so.1.0.2k 3 [ra] 0x0000ffffa4e4f564 ERR_error_string + 151 in libcrypto.so.1.0.2k 4 [ra] 0x0000ffffa5316d68 Curl_close + 135 in libcurl.so.4.8.0 5 [ra] 0x0000ffffa52c2374 Curl_conncache_close_all_connections + 371 in libcurl.so.4.8.0 6 [ra] 0x0000ffffa52f8884 curl_multi_cleanup + 215 in libcurl.so.4.8.0 7 [ra] 0x0000ffffa7b893b0 URLSession._MultiHandle.deinit + 255 in libFoundationNetworking.so 8 [ra] 0x0000ffffa7b895ec URLSession._MultiHandle.__deallocating_deinit + 11 in libFoundationNetworking.so 9 [ra] 0x0000ffffa8ce86f8 _swift_release_dealloc + 27 in libswiftCore.so 10 [ra] 0x0000ffffa8ce9290 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 207 in libswiftCore.so 11 [ra] 0x0000ffffa7b7d984 URLSession.deinit + 79 in libFoundationNetworking.so 12 [ra] 0x0000ffffa7b7d9d4 URLSession.__deallocating_deinit + 11 in libFoundationNetworking.so 13 [ra] 0x0000ffffa8ce86f8 _swift_release_dealloc + 27 in libswiftCore.so 14 [ra] 0x0000ffffa8ce9404 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSideTable<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 351 in libswiftCore.so 15 [ra] 0x0000ffffa7b40f9c objectdestroy.11Tm + 23 in libFoundationNetworking.so 16 [ra] 0x0000ffffa8ce86f8 _swift_release_dealloc + 27 in libswiftCore.so 17 [ra] 0x0000ffffa8ce9290 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 207 in libswiftCore.so 18 [ra] 0x0000ffffa81c71f0 BlockOperation.__deallocating_deinit + 31 in libFoundation.so 19 [ra] 0x0000ffffa8ce86f8 _swift_release_dealloc + 27 in libswiftCore.so 20 [ra] 0x0000ffffa8ce9290 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 207 in libswiftCore.so 21 [ra] 0x0000ffffa7fb5b48 objectdestroy.20Tm + 23 in libFoundation.so 22 [ra] 0x0000ffffa8ce86f8 _swift_release_dealloc + 27 in libswiftCore.so 23 [ra] 0x0000ffffa8ce9290 bool swift::RefCounts<swift::RefCountBitsT<(swift::RefCountInlinedness)1> >::doDecrementSlow<(swift::PerformDeinit)1>(swift::RefCountBitsT<(swift::RefCountInlinedness)1>, unsigned int) + 207 in libswiftCore.so 24 [ra] 0x0000ffffa84f4e3c _Block_release + 271 in libBlocksRuntime.so 25 [ra] 0x0000ffffa84bedf0 __destroy_helper_block_8_32c35_ZTS29dispatch_block_private_data_s + 91 in libdispatch.so 26 [ra] 0x0000ffffa84f4e3c _Block_release + 271 in libBlocksRuntime.so 27 [ra] 0x0000ffffa84aa96c _dispatch_continuation_pop + 235 in libdispatch.so 28 [ra] 0x0000ffffa84aa79c _dispatch_async_redirect_invoke + 183 in libdispatch.so 29 [ra] 0x0000ffffa84b5c38 _dispatch_worker_thread + 467 in libdispatch.so 30 [ra] 0x0000ffffa78b4230 start_thread + 175 in libpthread-2.26.so ```
1 parent 4dc41b0 commit c2028b5

File tree

2 files changed

+7
-17
lines changed

2 files changed

+7
-17
lines changed

Diff for: Sources/Build/BuildOperationBuildSystemDelegateHandler.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
8686
8787
fileprivate extension \#(className) {
8888
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
89-
@MainActor
9089
static let __allTests__\#(className) = [
9190
\#(testMethods.map { $0.allTestsEntry }.joined(separator: ",\n "))
9291
]
@@ -98,7 +97,6 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
9897
content +=
9998
#"""
10099
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
101-
@MainActor
102100
func __\#(module)__allTests() -> [XCTestCaseEntry] {
103101
return [
104102
\#(testsByClassNames.map { "testCase(\($0.key).__allTests__\($0.key))" }
@@ -167,7 +165,6 @@ final class TestDiscoveryCommand: CustomLLBuildCommand, TestBuildCommand {
167165
import XCTest
168166
169167
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
170-
@MainActor
171168
public func __allDiscoveredTests() -> [XCTestCaseEntry] {
172169
\#(testsKeyword) tests = [XCTestCaseEntry]()
173170
@@ -266,15 +263,18 @@ final class TestEntryPointCommand: CustomLLBuildCommand, TestBuildCommand {
266263
@main
267264
@available(*, deprecated, message: "Not actually deprecated. Marked as deprecated to allow inclusion of deprecated tests (which test deprecated functionality) without warnings")
268265
struct Runner {
266+
#if os(WASI)
267+
/// On WASI, we can't block the main thread, so XCTestMain is defined as async.
269268
static func main() async {
270269
\#(testObservabilitySetup)
271-
#if os(WASI)
272-
/// On WASI, we can't block the main thread, so XCTestMain is defined as async.
273270
await XCTMain(__allDiscoveredTests()) as Never
274-
#else
271+
}
272+
#else
273+
static func main() {
274+
\#(testObservabilitySetup)
275275
XCTMain(__allDiscoveredTests()) as Never
276-
#endif
277276
}
277+
#endif
278278
}
279279
"""#
280280
)

Diff for: Tests/CommandsTests/TestCommandTests.swift

-10
Original file line numberDiff line numberDiff line change
@@ -294,16 +294,6 @@ final class TestCommandTests: CommandsTestCase {
294294
}
295295
}
296296

297-
#if !canImport(Darwin)
298-
func testGeneratedMainIsConcurrencySafe_XCTest() throws {
299-
let strictConcurrencyFlags = ["-Xswiftc", "-strict-concurrency=complete"]
300-
try fixture(name: "Miscellaneous/TestDiscovery/Simple") { fixturePath in
301-
let (_, stderr) = try SwiftPM.Test.execute(strictConcurrencyFlags, packagePath: fixturePath)
302-
XCTAssertNoMatch(stderr, .contains("is not concurrency-safe"))
303-
}
304-
}
305-
#endif
306-
307297
func testLibraryEnvironmentVariable() throws {
308298
try fixture(name: "Miscellaneous/CheckTestLibraryEnvironmentVariable") { fixturePath in
309299
XCTAssertNoThrow(try SwiftPM.Test.execute(packagePath: fixturePath))

0 commit comments

Comments
 (0)