#expect crashes with EXC_BAD_ACCESS when condition comparing generics is false
Description
Hello, i found a strange issue while playing around with the testing library.
I will provide some more context later, but the reproduction is very simple: compare two objects in #expect, if the condition is false there is a crash, if the condition is true everything is ok.
I made a test with various samples but the ones causing an issue seem to be related to enums with generic. In the reproduction examples below the difference is that .playerStandUp are enums without generics and it works, and .roundEnded is an enum with generics and it fails.
That's the only difference that i see for now.
Expected behavior
Test fails providing some details about unfulfilled expectation
Actual behavior
Test crashes with a EXC_BAD_ACCESS (code=1, address=0x10)
Steps to reproduce
Run the test in the latest xcode
@Test("Why are you crashing")
func whyAreYouCrashing() async throws {
#expect(.roundEnded(
board: GenericBoard,
winningSides: [Blacks],
reason:.agreedDraw
) == .roundEnded(
board: GenericBoard,
winningSides: [Blacks],
reason:.abandon
))
}
But this one works (failed expectation as it should be)
@Test("Why do you work then")
func whyDoYouWorkThen() async throws {
#expect(.playerStandUp(
attendees: Attendees(
players: [:],
observers: []
),
playerId: "id-wrong",
side: Whites
) == .playerStandUp(
attendees: Attendees(
players: [:],
observers: []
),
playerId: "id-correct",
side: Whites
))
}
swift-testing version/commit hash
Swift & OS version (output of swift --version ; uname -a)
swift-driver version: 1.115 Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
No response
Hmm i was trying to produce an easily reproductible sample but without success for now, i will keep trying. The code that fails (looking at the trace) fails somewhere here
#0 0x00000001a68b8000 in _swift_buildDemanglingForMetadata ()
swiftlang/swift-testing#21 0x000000010338c3a8 in Testing.__checkBinaryOperation<τ_0_0, τ_0_1>(_: τ_0_0, _: (τ_0_0, () -> τ_0_1) -> Swift.Bool, _: @autoclosure () -> τ_0_1, expression: Testing.__Expression, comments: @autoclosure () -> Swift.Array<Testing.Comment>, isRequired: Swift.Bool, sourceLocation: Testing.SourceLocation) -> Swift.Result<(), Swift.Error> ()
For now it is not blocking as tests should pass anyway but it could make tracking any bug a little bit harder
Looks like a runtime crash. Forwarding to the runtime team to triage.
@master-bytes-krafter Could you post a full crash log? If you're getting this in the debugger, type detach at the (lldb) prompt and it should proceed with crashing and produce a log you can find in Console.app. A reproducer would be great too, but sounds like that's hard to come by here.
Hello, please find the log here:
Process: xctest [96569]
Path: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Agents/xctest
Identifier: xctest
Version: ???
Code Type: ARM-64 (Native)
Parent Process: lldb-rpc-server [62711]
User ID: 501
Date/Time: 2024-09-24 08:43:30.9570 +0200
OS Version: macOS 14.6.1 (23G93)
Report Version: 12
Anonymous UUID: 057932FA-EC09-7775-73DB-E05531DB7D76
Sleep/Wake UUID: AA3F2464-C006-4631-B624-53F5381555C7
Time Awake Since Boot: 420000 seconds
Time Since Wake: 660 seconds
System Integrity Protection: enabled
Crashed Thread: 3
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000010
Exception Codes: 0x0000000000000001, 0x0000000000000010
Termination Reason: Namespace SIGNAL, Code 11 Segmentation fault: 11
Terminating Process: exc handler [96569]
External Modification Warnings:
Debugger attached to process.
VM Region Info: 0x10 is not in any region. Bytes before following region: 4294967280
REGION TYPE START - END [ VSIZE] PRT/MAX SHRMOD REGION DETAIL
UNUSED SPACE AT START
--->
__TEXT 100000000-100004000 [ 16K] r-x/rwx SM=COW /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Agents/xctest
Thread 0:: Dispatch queue: com.apple.main-thread
0 libdispatch.dylib 0x1966bc440 voucher_mach_msg_revert + 0
1 CoreFoundation 0x19692568c __CFRunLoopServiceMachPort + 172
2 CoreFoundation 0x196923f44 __CFRunLoopRun + 1208
3 CoreFoundation 0x196923434 CFRunLoopRunSpecific + 608
4 XCTestCore 0x100d56018 +[XCTWaiter _synchronouslyWaitForTimeInterval:] + 252
5 XCTestCore 0x100d56864 -[XCTWaiter _performWait:manager:completionHandler:] + 1068
6 XCTestCore 0x100d5448c -[XCTWaiter _waitForExpectations:timeout:enforceOrder:synchronously:completionHandler:] + 580
7 XCTestCore 0x100d541f8 -[XCTWaiter waitForExpectations:timeout:enforceOrder:] + 136
8 XCTestCore 0x100d1bc84 __XCTAsyncEnumerateWithWaiter_block_invoke + 308
9 XCTestCore 0x100d1be04 __XCTAsyncEnumerate_block_invoke.116 + 64
10 XCTestCore 0x100d1bd90 __XCTAsyncEnumerateWithWaiter_block_invoke_2 + 52
11 XCTestCore 0x100d1a920 __72-[XCTExecutionWorker enqueueTestIdentifiersToRun:testIdentifiersToSkip:]_block_invoke_3 + 132
12 XCTestCore 0x100d28570 -[XCTTestRunSession executeTestsWithIdentifiers:skippingTestsWithIdentifiers:completion:] + 328
13 XCTestCore 0x100d1a85c __72-[XCTExecutionWorker enqueueTestIdentifiersToRun:testIdentifiersToSkip:]_block_invoke_2 + 148
14 XCTestCore 0x100d1bc50 __XCTAsyncEnumerateWithWaiter_block_invoke + 256
15 XCTestCore 0x100d1be04 __XCTAsyncEnumerate_block_invoke.116 + 64
16 XCTestCore 0x100d1a6c0 XCTAsyncEnumerateWithWaiter + 584
17 XCTestCore 0x100d1a42c __72-[XCTExecutionWorker enqueueTestIdentifiersToRun:testIdentifiersToSkip:]_block_invoke + 136
18 XCTestCore 0x100d1a9a0 -[XCTExecutionWorker runWithError:] + 84
19 XCTestCore 0x100d187fc __25-[XCTestDriver _runTests]_block_invoke.289 + 56
20 XCTestCore 0x100d32768 -[XCTestObservationCenter _observeTestExecutionForTestBundle:inBlock:] + 212
21 XCTestCore 0x100d181a4 -[XCTestDriver _runTests] + 1156
22 XCTestCore 0x100d1a0ac _XCTestMain + 120
23 xctest 0x100002b30 static xctest.main() + 428
24 xctest 0x100002c28 static xctest.$main() + 12
25 xctest 0x100002c3c main + 12
26 dyld 0x1964bb154 start + 2476
Thread 1:
0 libsystem_pthread.dylib 0x196840d20 start_wqthread + 0
Thread 2:
0 libsystem_pthread.dylib 0x196840d20 start_wqthread + 0
Thread 3 Crashed:
0 libswiftCore.dylib 0x1a68b8000 _swift_buildDemanglingForMetadata + 432
1 libswiftCore.dylib 0x1a68b4154 swift_getMangledTypeName + 584
2 libswiftCore.dylib 0x1a66914d4 _mangledTypeName(_:) + 20
3 Testing 0x103ccf8d0 TypeInfo.isSwiftEnumeration.getter + 156
4 Testing 0x103d138a8 specialized String.init<A>(describingForTest:) + 1500
5 Testing 0x103d197a8 __Expression.Value.init(_reflecting:label:seenObjects:) + 1444
6 Testing 0x103d19e08 closure #1 in __Expression.Value.init(_reflecting:label:seenObjects:) + 132
7 Testing 0x103d21998 partial apply for closure #1 in __Expression.Value.init(_reflecting:label:seenObjects:) + 24
8 Testing 0x103d219bc partial apply for specialized thunk for @callee_guaranteed (@in_guaranteed A) -> (@out A1, @error @out B1) + 28
9 libswiftCore.dylib 0x1a652e3c8 Collection.map<A>(_:) + 724
10 libswiftCore.dylib 0x1a6600fb4 _RandomAccessCollectionBox._map<A>(_:) + 284
11 libswiftCore.dylib 0x1a6880b5c dispatch thunk of _AnySequenceBox._map<A>(_:) + 48
12 Testing 0x103d19b18 __Expression.Value.init(_reflecting:label:seenObjects:) + 2324
13 Testing 0x103d1a158 closure #1 in __Expression.capturingRuntimeValue<A>(_:) + 152
14 Testing 0x103d218b0 partial apply for closure #1 in __Expression.capturingRuntimeValue<A>(_:) + 24
15 Testing 0x103d16554 $sSq3mapyqd_0_Sgqd_0_xqd__YKXEqd__YKs5ErrorRd__Ri_d_0_r0_lF + 516
16 Testing 0x103d16ecc __Expression.capturingRuntimeValue<A>(_:) + 456
17 Testing 0x103d1763c __Expression.capturingRuntimeValues<each A, B>(_:_:) + 1068
18 Testing 0x103d177cc __Expression.capturingRuntimeValues<each A, B>(_:_:) + 1468
19 Testing 0x103ca8604 implicit closure #1 in __checkBinaryOperation<A, B>(_:_:_:expression:comments:isRequired:sourceLocation:) + 528
20 Testing 0x103ca635c __checkValue(_:expression:expressionWithCapturedRuntimeValues:mismatchedErrorDescription:difference:mismatchedExitConditionDescription:comments:isRequired:sourceLocation:) + 860
21 Testing 0x103ca83a8 __checkBinaryOperation<A, B>(_:_:_:expression:comments:isRequired:sourceLocation:) + 576
22 KBBoardGamesLocalGamesTests 0x103394dc8 $s017KBBoardGamesLocalB5Tests0038KBBoardGamesLocalGamesTestsswift_yoBAmfMX918_5_6expectfMf_ + 804 (@__swiftmacro_017KBBoardGamesLocalB5Tests0038KBBoardGamesLocalGamesTestsswift_yoBAmfMX918_5_6expectfMf_.swift:1) [inlined]
23 KBBoardGamesLocalGamesTests 0x103394dc8 KBBoardGamesLocalGamesTests.LoadingAGame.whyAreYouCrashing() + 928 (KBBoardGamesLocalGamesTests.swift:919)
24 KBBoardGamesLocalGamesTests 0x103394791 static KBBoardGamesLocalGamesTests.LoadingAGame.$s017KBBoardGamesLocalB5TestsAAV12LoadingAGameV17whyAreYouCrashing4TestfMp_34funcwhyAreYouCrashing__asyncthrowsfMu0_@Sendable () + 1 (@__swiftmacro_017KBBoardGamesLocalB5TestsAAV12LoadingAGameV17whyAreYouCrashing4TestfMp_.swift:4)
25 KBBoardGamesLocalGamesTests 0x10339516d implicit closure #1 in static KBBoardGamesLocalGamesTests.LoadingAGame.$s017KBBoardGamesLocalB5TestsAAV12LoadingAGameV17whyAreYouCrashing4TestfMp_64__🟠$test_container__function__funcwhyAreYouCrashing__asyncthrowsfMu_.__tests.getter + 1 (@__swiftmacro_017KBBoardGamesLocalB5TestsAAV12LoadingAGameV17whyAreYouCrashing4TestfMp_.swift:18)
26 Testing 0x103ce2d51 closure #1 in closure #1 in Runner._runTestCase(_:within:) + 1
27 Testing 0x103cc22b1 partial apply for closure #1 in closure #1 in Test.Case.Generator.init<A, B>(sequence:parameters:testFunction:) + 1
28 Testing 0x103cbf13d specialized static Issue.withErrorRecording(at:configuration:_:) + 1
29 Testing 0x103ce2269 closure #1 in Runner._runTestCase(_:within:) + 1
30 Testing 0x103cc22b1 partial apply for closure #1 in closure #1 in Test.Case.Generator.init<A, B>(sequence:parameters:testFunction:) + 1
31 Testing 0x103ce4569 specialized static Test.Case.withCurrent<A>(_:perform:) + 1
32 Testing 0x103ce1ce1 Runner._runTestCase(_:within:) + 1
33 Testing 0x103ce175d closure #2 in Runner._runTestCases<A>(_:within:) + 1
34 Testing 0x103cc22b1 partial apply for closure #1 in closure #1 in Test.Case.Generator.init<A, B>(sequence:parameters:testFunction:) + 1
35 Testing 0x103ced451 specialized closure #1 in closure #1 in Runner._forEach<A, B>(in:for:_:) + 1
36 Testing 0x103cc22b1 partial apply for closure #1 in closure #1 in Test.Case.Generator.init<A, B>(sequence:parameters:testFunction:) + 1
37 libswift_Concurrency.dylib 0x25e0c60f9 completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1
Thread 4:
0 libsystem_pthread.dylib 0x196840d20 start_wqthread + 0
Thread 5:
0 libsystem_pthread.dylib 0x196840d20 start_wqthread + 0
Thread 6:
0 libsystem_pthread.dylib 0x196840d20 start_wqthread + 0
Thread 7:
0 libsystem_kernel.dylib 0x196807c1c __disable_threadsignal + 8
1 libsystem_pthread.dylib 0x196846654 _pthread_exit + 36
2 libsystem_pthread.dylib 0x1968435cc _pthread_wqthread_exit + 64
3 libsystem_pthread.dylib 0x196842094 _pthread_wqthread + 424
4 libsystem_pthread.dylib 0x196840d28 start_wqthread + 8
Thread 8:
0 libsystem_pthread.dylib 0x196840d20 start_wqthread + 0
Thread 3 crashed with ARM Thread State (64-bit):
x0: 0x0000000000000000 x1: 0x00000001700b3d90 x2: 0x00000001700b3d90 x3: 0x0000000000000005
x4: 0x0000000000000002 x5: 0x000000000000000e x6: 0x0000000000000064 x7: 0x0000000000000000
x8: 0x0000000000000307 x9: 0x000000015305dcc8 x10: 0x000000015305dcc8 x11: 0x000000015305ca0f
x12: 0x0000000000000004 x13: 0x0000000153043800 x14: 0xfffffffffffffffe x15: 0x0000000000000001
x16: 0x00000001a68b9a38 x17: 0x00000001a68b7eb4 x18: 0x0000000000000000 x19: 0x00000001700b3d90
x20: 0x000000015305ca20 x21: 0x000000015305ca08 x22: 0x000000014302a01e x23: 0x0000000000000000
x24: 0x0000000000000005 x25: 0x000000015305ca38 x26: 0x0000000000000006 x27: 0x000000014302a0e8
x28: 0x0000000200633be8 fp: 0x00000001700b3d10 lr: 0xbe058001a68b7ffc
sp: 0x00000001700b3ba0 pc: 0x00000001a68b8000 cpsr: 0x60001000
far: 0x0000000000000010 esr: 0x92000006 (Data Abort) byte read Translation fault
Binary Images:
0x10333c000 - 0x1033f7fff local-games.KBBoardGamesLocalGamesTests (*) <001347ba-754a-3ac0-8361-73abeee4ee71> /Users/USER/Library/Developer/Xcode/DerivedData/local-games-ftoduydhjxzedsacwdvgtvwhndfv/Build/Products/Variant-NoSanitizers/Debug/KBBoardGamesLocalGamesTests.xctest/Contents/MacOS/KBBoardGamesLocalGamesTests
0x1000ec000 - 0x1001b7fff libXCTestSwiftSupport.dylib (*) <02933e08-1472-3f8b-8258-2ccd5fc16373> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/libXCTestSwiftSupport.dylib
0x103c58000 - 0x103d73fff com.apple.dt.swift-testing (1.0) <5997cbb0-8433-3e5d-8c34-302453fdce9a> /Applications/Xcode.app/Contents/SharedFrameworks/Testing.framework/Versions/A/Testing
0x103530000 - 0x1038cffff com.apple.CoreDevice (397.21) <adf86974-de00-31c0-b4e0-15df98ae0956> /Library/Developer/PrivateFrameworks/CoreDevice.framework/Versions/A/CoreDevice
0x100368000 - 0x1003affff com.apple.dt.CoreDevice.Utilities (397.21) <641f0c75-31fa-37e1-bf24-e8b64ccff2b2> /Library/Developer/PrivateFrameworks/CoreDeviceUtilities.framework/Versions/A/CoreDeviceUtilities
0x1002f0000 - 0x10031bfff com.apple.dt.CoreDevice.Action (397.21) <f34ad337-0e41-3977-a9e2-2e7d0e83585d> /Library/Developer/PrivateFrameworks/CoreDevice.framework/Versions/A/Frameworks/CoreDeviceAction.framework/Versions/A/CoreDeviceAction
0x104cb4000 - 0x1050c3fff com.apple.mobiledevice (1759.2.1) <ef1e281c-f523-3f75-99aa-0bc7418ea4b3> /Library/Apple/*/MobileDevice.framework/Versions/A/MobileDevice
0x101018000 - 0x101097fff com.apple.Mercury (1.0) <c5522bad-43fb-3b14-b85f-b8b5a19477b3> /Library/Apple/*/Mercury.framework/Versions/A/Mercury
0x1011c4000 - 0x101237fff com.apple.CoreDevice.DTRemoteServices (1.0) <8192d03b-5a1e-30c3-b164-dea95ae64e00> /Library/Developer/PrivateFrameworks/CoreDevice.framework/Versions/A/Frameworks/DTRemoteServices.framework/Versions/A/DTRemoteServices
0x1004b0000 - 0x100507fff com.apple.dt.XCTAutomationSupport (16.0) <0385ea1b-8b07-34b7-97c9-9cb6c23890fd> /Applications/Xcode.app/Contents/SharedFrameworks/XCTAutomationSupport.framework/Versions/A/XCTAutomationSupport
0x100460000 - 0x100463fff com.apple.dt.XCTest (16.0) <84b126e5-a182-3f4d-8e4a-7b7ef261ddfd> /Applications/Xcode.app/Contents/SharedFrameworks/XCTest.framework/Versions/A/XCTest
0x100484000 - 0x100487fff com.apple.dt.XCTestSupport (16.0) <09501e7e-1a62-37fa-9dee-26856d1bfa00> /Applications/Xcode.app/Contents/SharedFrameworks/XCTestSupport.framework/Versions/A/XCTestSupport
0x1007a8000 - 0x1007d3fff com.apple.dt.instruments.DTXConnectionServices (16.0) <da6bac29-6c8a-3e38-81ab-c1f5b0216d88> /Applications/Xcode.app/Contents/SharedFrameworks/DTXConnectionServices.framework/Versions/A/DTXConnectionServices
0x100ccc000 - 0x100db3fff com.apple.dt.XCTestCore (16.0) <e78f0273-ad9a-3007-886a-0bd67aa10f4d> /Applications/Xcode.app/Contents/SharedFrameworks/XCTestCore.framework/Versions/A/XCTestCore
0x1006e8000 - 0x1006ebfff com.apple.dt.XCUnit (16.0) <323dcab3-8f1b-387a-970c-4bf746286888> /Applications/Xcode.app/Contents/SharedFrameworks/XCUnit.framework/Versions/A/XCUnit
0x1007e8000 - 0x1008effff com.apple.dt.XCUIAutomation (16.0) <46d0b8dd-95a2-3d7b-b854-54aefe554918> /Applications/Xcode.app/Contents/SharedFrameworks/XCUIAutomation.framework/Versions/A/XCUIAutomation
0x1009c8000 - 0x100adbfff com.apple.CoreSymbolicationDT (16.0) <ec6b215b-6fed-3a3d-bfc4-c18cac49a4b8> /Applications/Xcode.app/Contents/SharedFrameworks/CoreSymbolicationDT.framework/Versions/A/CoreSymbolicationDT
0x1012b4000 - 0x1013c3fff com.apple.dt.instruments.DVTInstrumentsFoundation (16.0) <cbd7dcce-5f80-353d-991c-842c3eebb137> /Applications/Xcode.app/Contents/SharedFrameworks/DVTInstrumentsFoundation.framework/Versions/A/DVTInstrumentsFoundation
0x100e78000 - 0x100f6ffff com.apple.SymbolicationDT (16.0) <2e646eca-ce66-3045-9b0b-287bef912923> /Applications/Xcode.app/Contents/SharedFrameworks/SymbolicationDT.framework/Versions/A/SymbolicationDT
0x1006f8000 - 0x10071ffff com.apple.DebugSymbols (209) <ca1cb6da-f3e1-3827-a296-a5f5c033f6f0> /Applications/Xcode.app/Contents/SharedFrameworks/DebugSymbolsDT.framework/Versions/A/DebugSymbolsDT
0x100568000 - 0x100573fff com.apple.kperfdataDT (1.0) <8fcab898-976c-3ca3-b12d-eb207fc17797> /Applications/Xcode.app/Contents/SharedFrameworks/kperfdataDT.framework/Versions/A/kperfdataDT
0x10077c000 - 0x100783fff com.apple.MallocStackLogging (1.0) <eadf6cdc-5ba9-3581-8b53-abd0febb9620> /Applications/Xcode.app/Contents/SharedFrameworks/MallocStackLoggingDT.framework/Versions/A/MallocStackLoggingDT
0x100bc4000 - 0x100c1ffff com.apple.libktrace (1.0) <7b994288-4b71-31c7-8249-b83b546685b6> /Applications/Xcode.app/Contents/SharedFrameworks/ktraceDT.framework/Versions/A/ktraceDT
0x101158000 - 0x10119bfff com.apple.dt.instruments.DVTInstrumentsUtilities (16.0) <947ebe95-fa82-3203-a580-bcc2cb74ee56> /Applications/Xcode.app/Contents/SharedFrameworks/DVTInstrumentsUtilities.framework/Versions/A/DVTInstrumentsUtilities
0x100594000 - 0x1005d7fff libMainThreadChecker.dylib (*) <688f1141-b767-3960-9ed4-b2847032dfbb> /Applications/Xcode.app/Contents/Developer/usr/lib/libMainThreadChecker.dylib
0x10049c000 - 0x10049ffff libLogRedirect.dylib (*) <f691ea47-c391-3a52-97c5-42f5543314f6> /Applications/Xcode.app/Contents/Developer/usr/lib/libLogRedirect.dylib
0x100000000 - 0x100003fff xctest (*) <e49ec24e-7dc6-3901-a304-cde4cc08fa53> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Xcode/Agents/xctest
0x196691000 - 0x1966d8fff libdispatch.dylib (*) <1a1ce00a-89cd-36ba-9678-5038aedd0d8d> /usr/lib/system/libdispatch.dylib
0x1968a7000 - 0x196d7ffff com.apple.CoreFoundation (6.9) <55720ee0-d8c3-33a1-9854-8e61a6f44895> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
0x1964b5000 - 0x19653e507 dyld (*) <f635824e-318b-3f0c-842c-c369737f2b68> /usr/lib/dyld
0x0 - 0xffffffffffffffff ??? (*) <00000000-0000-0000-0000-000000000000> ???
0x196804000 - 0x19683effb libsystem_kernel.dylib (*) <71ff45b8-f14e-3666-9e96-6cf58315b91d> /usr/lib/system/libsystem_kernel.dylib
0x19683f000 - 0x19684bfff libsystem_pthread.dylib (*) <e03e8478-6f5c-3d21-a79a-58408f514000> /usr/lib/system/libsystem_pthread.dylib
0x1a6517000 - 0x1a6a74fff libswiftCore.dylib (*) <7db1818b-1d9a-328e-821b-21a33442746a> /usr/lib/swift/libswiftCore.dylib
0x25e070000 - 0x25e0dbff7 libswift_Concurrency.dylib (*) <304344ae-67eb-3702-b525-14332583111e> /usr/lib/swift/libswift_Concurrency.dylib
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 1
thread_create: 0
thread_set_state: 34
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 386
thread_create: 0
thread_set_state: 6410
As for the repro i am still trying, the actual code crashes in module/package (not sure about swift terminology here, still learning) B tests, those enums come from module A which was compiled (?) or at least uses swift version prior to 6. I will try to setup something similar
We're trying to get the name for a tuple type. That requires getting the name for all the elements. That failed for one of the elements, and the code doesn't tolerate failure and crashes.
This may actually be fixed by my change here: https://github.com/swiftlang/swift/pull/71664. But that doesn't help you on macOS 14.
Maybe this info will help you narrow down the troublesome type. If you have tuples in here somewhere (I think enum associated types with more than one value are implicitly represented with tuples), you can try removing or changing them one by one until you find the one that causes the issue. Even with my fix above, it seems likely that there's another problem in here, since we should probably be able to generate this name, and my fix just makes it fail more gracefully.
Ok thank you for the info, i will look into this direction
The problem seems to go away once i updated macos version to 15. So i guess it is somehow related to the previous os version ?
15 has the fix from https://github.com/swiftlang/swift/pull/71664 so that may be why it's no longer crashing for you.
I’m encountering the same issue:
When I extract the result of the comparison into a separate variable and pass it to the #expect macro, it works as expected. The test fails as intended when the assertion is incorrect:
@Test
func xmlParser() {
// Given
let data = data(resource: "Sample", withExtension: "xml")
let parser = XMLParser(data: data)
let expected: XMLNode = xmlNodeMock
// When
let actual = try? parser.parse().get().root
// This works
let result = expected == actual
// Then
#expect(result)
}
However, if I pass the comparison directly to the #expect macro, it doesn’t behave correctly. Instead of failing the test as expected, it crashes:
@Test
func xmlParser() {
// Given
let data = data(resource: "Sample", withExtension: "xml")
let parser = XMLParser(data: data)
let expected: XMLNode = xmlNodeMock
// When
let actual = try? parser.parse().get().root
// Then
#expect(expected == actual)
}
The crash produces the following error:
Thread 7: EXC_BAD_ACCESS (code=2, address=0x1700bffc0)
Testing.__checkBinaryOperation(expected, {
$0 == $1()
}, actual, expression: .__fromBinaryOperation(.__fromSyntaxNode("expected"), "==", .__fromSyntaxNode("actual")), comments: [.__line("// Then")], isRequired: false, sourceLocation: Testing.SourceLocation.__here()).__expected()
It seems like the macro fails when directly asserting a binary operation (expected == actual).
This can be reproduced in the v10 branch of the FeedKit library, by changing the test case slightly in the SampleTests.swift file.
@Test
func xmlParser() {
// Given
let data = data(resource: "Sample", withExtension: "xml")
let parser = XMLParser(data: data)
let expected: XMLNode = xmlNodeMock
// Change a variable name here
expected.name = "make it fail"
// When
let actual = try? parser.parse().get().root
// Then
#expect(expected == actual)
}
Running:
swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
Xcode 16.1 (16B40)
MacOS 15.1.1 (24B91)
@nmdias Can you gather a crash backtrace so we can confirm if it's the same issue?
@nmdias Thank you — yes, that crash log helps confirm that this is a different issue. I believe this may have been fixed by https://github.com/swiftlang/swift-testing/pull/787
(As an aside: that crash log file is quite lengthy. Any chance you could edit your comment so that the log is a file attachment instead? Just to avoid distracting from this ongoing issue. Thanks!)
@nmdias Thank you — yes, that crash log helps confirm that this is a different issue. I believe this may have been fixed by swiftlang/swift-testing#787
(As an aside: that crash log file is quite lengthy. Any chance you could edit your comment so that the log is a file attachment instead? Just to avoid distracting from this ongoing issue. Thanks!)
@stmontgomery Done!
Do you know if that fix already shipped in the latest Swift version?
Thanks!
Do you know if that fix already shipped in the latest Swift version?
I don't believe that fix has shipped in any release yet. I can look into pulling it in to an earlier Swift release.
@stmontgomery I'm in no hurry. Thank you for letting me know and for your help.