Xcode 13b1
Update: Nevermind, my network Combine chain had a .breakpoint()
operator in it, which seems arbitrary in where it dumps you in the debugger.
I'm running into something I don't understand. While executing some code I just wrote, Xcode stops in the debugger with SIGTRAP on a mov instruction, but I can continue execution apparently without issue, and the code seems to produce the desired result.
Unfortunately, when not run in the debugger, it just crashes.
The stack looks like this:
#0 0x00007fff2ffa41a0 in swift_conformsToSwiftProtocolImpl(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, llvm::StringRef) ()
#1 0x00007fff2ffa4006 in swift_conformsToProtocolImpl(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*) ()
#2 0x00007fff2ff7413a in swift::_conformsToProtocol(swift::OpaqueValue const*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptorRef<swift::InProcess>, swift::TargetWitnessTable<swift::InProcess> const**) ()
#3 0x00007fff2ff77967 in _conformsToProtocols(swift::OpaqueValue const*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::TargetWitnessTable<swift::InProcess> const**) ()
#4 0x00007fff2ff76d45 in _dynamicCastToExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::DynamicCastFlags) ()
#5 0x00007fff2fd0d9b8 in _debugPrint_unlocked<τ_0_0, τ_0_1>(_:_:) ()
#6 0x00007fff2fda8261 in specialized _debugPrint<τ_0_0>(_:separator:terminator:to:) ()
#7 0x00007fff2fc758c9 in Array.description.getter ()
#8 0x00007fff2fca13ea in DefaultStringInterpolation.appendInterpolation<τ_0_0>(_:) ()
#9 0x0000000104e7c2e9 in closure #2 in MySavedItems.load() at MySavedItems.swift:48
#10 0x0000000104e7c5da in thunk for @escaping @callee_guaranteed (@guaranteed MySavedItemsQuery.Response) -> () ()
#11 0x00007fff4b9f0dd6 in Subscribers.Sink.receive(_:) ()
#12 0x00007fff4b9f14d0 in protocol witness for Subscriber.receive(_:) in conformance Subscribers.Sink<τ_0_0, τ_0_1> ()
#13 0x00007fff4ba264e7 in closure #1 in Publishers.ReceiveOn.Inner.receive(_:) ()
…
#25 0x0000000104ac3188 in static UIApplicationDelegate.main() ()
#26 0x0000000104ac3117 in static AppDelegate.$main() at …/AppDelegate.swift:10
#27 0x0000000104ac3208 in main ()
#28 0x00007fff2025a3e9 in start ()
#29 0x00007fff2025a3e9 in start ()
The particular section of code leading up to the line on which it stops:
0x7fff2ffa418e <+238>: callq 0x7fff2ffa4650 ; ConformanceState::cacheSuccess(void const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, swift::TargetProtocolConformanceDescriptor<swift::InProcess> const*)
0x7fff2ffa4193 <+243>: movq -0x50(%rbp), %rbx
0x7fff2ffa4197 <+247>: addq $0x4, %r12
0x7fff2ffa419b <+251>: cmpq %r12, %r14
0x7fff2ffa419e <+254>: je 0x7fff2ffa4150 ; <+176>
-> 0x7fff2ffa41a0 <+256>: movslq (%r12), %r15
And my code:
func
load()
{
…
let q = MySavedItemsQuery()
let pub = try! client.perform(query: q)
pub
.receive(on: DispatchQueue.main)
.sink { inCompletion in
switch (inCompletion) {
case .failure(let e):
debugLog("Failure: \(e)")
case .finished:
debugLog("Finished")
}
}
receiveValue: { inResp in
let listings = inResp.listings
let count = listings.count
debugLog("\(count) listings: \(listings)") <----- Error occurs here
if self.listings == nil {
self.listings = inResp.listings
} else {
self.listings!.append(contentsOf: inResp.listings ?? [])
}
}
.store(in: &self.subs)
MySavedItemsQuery
is a struct that conforms to WNQuery
:
protocol
WNQuery
{
associatedtype Response : Unmarshaling
var body: String { get }
var variables: [String:Any] { get }
static func parseResponse(object inObj: MarshaledObject) throws -> Response
}
and it defines Response
as
struct MySavedItemsQuery : WNQuery {
…
struct Response {
let listings : [Listing]
let pageInfo : PageInfo
}
…
extension MySavedItemsQuery.Response : Unmarshaling {
// Unmarshaling conformance
}
I'm at a loss. Something about my protocol conformance?