I am fighting a strange issue in unit tests of my iOS application. I use
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1188.8.131.52) and unfortunately I am unable to quickly verify the issue against latest Swift compiler. Sorry, I will try to verify the issue on the latest Swift version and I will try to pinpoint the minimal scenario to reproduce it, but before that I have a question regarding Swift ABI – just to make sure I took the right direction. Can anyone verify the technical details I shared right below?
My unit tests crash when I pass an
Equatable enum into
XCTAssertEqual tries to read an argument metadata, but this causes the stack pointer to be broken, which in turn causes
EXC_BAD_INSTRUCTION on the nearest
I see an anomaly in the enum metadata:
- a value witness table pointer comes first,
- then some unexpected pointer,
- then a
- finally a nominal type descriptor.
I am not sure if I haven't missed anything reading ABI docs, but this unexpected pointer seems unusual. As far as I know
kind value should appear immediately after the value witness table pointer.
XCTAssertEqual tries to get a value witness table at offset -0x8 from the type metadata, but instead of value witness table – it gets a pointer to something different.
My question is: is it correct for a full type metadata to have value witness table separated from
kind value by any additional data? Please help