Hi,
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-1200.0.32.28)
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
. 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 callq
instruction.
I see an anomaly in the enum metadata:
- a value witness table pointer comes first,
- then some unexpected pointer,
- then a
kind
, - 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