KeyPath test case (v5.0) failed on big-endian platform


(Sam Ding) #1

KeyPath (test/stdlib/KeyPathMultiModule.swift) of v5 tests failed on s390x. Here is a simplified sample code:

    import KeyPathMultiModule_b
    class LocalSub: ResilientSub {

    final var storedD: String = "zim"
    final var storedE: String = "zang"

   let a =  \LocalSub.storedD
   let b =  \LocalSub.storedE
   let cc = a == b                         // on s390x `cc` is true, but on x86_64 is false
   print (" cc =\(cc)")

Debugging this code on both x86_64 and s390x, I found the memory layout of a and b is different on x86_64, but is the same on s390x, which causes the test case failure.

The memory layout should be generated during the compiling.
My question here is what compiler code ( possible related to stdlib/public/core/KeyPath.swift) does generate the memory layout of variable a and b?
Could you please give me clue to fix this issue?


(Sam Ding) #2

More Info:

If replace the import KeyPathMultiModule_b with including file test/stdlib/Inputs/KeyPathMultiModule_b.swift, then we get the same output as on x86_64.
It seems that it is not working when build test/stdlib/Inputs/KeyPathMultiModule_b.swift separately on s390x.
Any ideas on this?

(Joe Groff) #3

It sounds like the bug may have to do with the instantiation of external key path property descriptors then. I suspect that the most likely cause of this problem will be in the runtime implementation for key paths; maybe it's another Int vs Int32 mismatch along the lines of I would check the key path pattern instantiation code in _walkKeyPathPattern having to do with external references against the code that traverses the instantiated key path object in AnyKeyPath.== to compare them.

(Sam Ding) #4

Thanks @Joe_Groff

A quick question, if change the above sample code as

    final var storedD: String = "abc"
    final var storedE: String = "abc"

Should cc be true? but actually it is false on x86_64.

(Joe Groff) #5

It should be false. Key paths should only compare equal if they refer to the same property.