New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-404] Loading Foundation protocol conformances fails #43021
Comments
NSKeyedArchiver needs this fixed to work on Linux. |
This may be the same as SR-310. |
This might be related to cast optimization code. I don't remember if our cast optimizations are guaranteed though. Does this happen with optimization? |
debug build of everything if that helps (and Linux only) |
Thanks! |
Not sure if this is helpful: if I call ProtocolConformanceRecord::dump() from swift::swift_conformsToProtocol(), I'm not seeing any Foundation types. Still investigating. for (; sectionIdx < endSectionIdx; ++sectionIdx) {
auto §ion = C.SectionsToScan[sectionIdx];
// Eagerly pull records for nondependent witnesses into our cache.
for (const auto &record : section) {
record.dump(); |
Another datapoint: in _addImageProtocolConformances() for libFoundation.so, conformancesSize is zero. (lldb) x conformances-8
0x7ffff685e330: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
0x7ffff685e340: 01 00 00 00 00 00 00 00 75 00 00 00 00 00 00 00 ........u....... (-8 as dump was after conformances += 8) |
Is _addImageProtocolConformances() right? .swift2_protocol_conformances_start is a section not a symbol? I don't know if you can use dlsym() here... Edit: sorry, my bad, dlsym("swift2_protocol_conformances_start") does work, the problem is elsewhere. |
lukeh@ubuntu:~/CVSRoot/apple/swift$ readelf -x .swift2_protocol_conformances ../build/Ninja-DebugAssert/foundation-linux-x86_64/Foundation/libFoundation.so
Hex dump of section '.swift2_protocol_conformances':
0x008dba38 7142fdff 5442fdff 00000000 01000000 qB..TB..........
0x008dba48 00000000 743bfeff 00000000 0f000000 ....t;..........
... vs lukeh@ubuntu:~/CVSRoot/apple/swift$ readelf -x .swift2_protocol_conformances ../build/Ninja-DebugAssert/swift-linux-x86_64/lib/swift/linux/libswiftCore.so
Hex dump of section '.swift2_protocol_conformances':
0x0083a578 20300000 00000000 00000000 00000000 0..............
0x0083a588 00000000 04000000 00000000 00000000 ................ with the latter under the debugger: (lldb) x conformances conformances+1024
0x7ffff7da6578: 20 30 00 00 00 00 00 00 10 c1 00 00 54 49 02 00 0..........TI..
0x7ffff7da6588: 48 17 01 00 04 00 00 00 b0 6e 00 00 44 49 02 00 H........n..DI..
0x7ffff7da6598: 48 17 01 00 04 00 00 00 a0 6e 00 00 cc 4a 02 00 H........n...J..
0x7ffff7da65a8: c0 17 01 00 04 00 00 00 48 b4 00 00 64 4c 02 00 ........H...dL.. |
More investigation, this program enumerates linked libraries with conformance sections and prints the first 32 bytes of them – also it prints the filename as returned by dladdr(). file: /home/lukeh/CVSRoot/apple/build/Ninja-DebugAssert/foundation-linux-x86_64/Foundation/libFoundation.so
dladdr(/home/lukeh/CVSRoot/apple/build/Ninja-DebugAssert/foundation-linux-x86_64/Foundation/libFoundation.so): /home/lukeh/CVSRoot/apple/build/Ninja-DebugAssert/swift-linux-x86_64/lib/swift/linux/x86_64/libswiftGlibc.so .swift2_protocol_conformances_start
00000000000000000000000000000000
01000000000000007500000000000000
file: /home/lukeh/CVSRoot/apple/build/Ninja-DebugAssert/swift-linux-x86_64/lib/swift/linux/x86_64/libswiftGlibc.so
dladdr(/home/lukeh/CVSRoot/apple/build/Ninja-DebugAssert/swift-linux-x86_64/lib/swift/linux/x86_64/libswiftGlibc.so): /home/lukeh/CVSRoot/apple/build/Ninja-DebugAssert/swift-linux-x86_64/lib/swift/linux/x86_64/libswiftGlibc.so .swift2_protocol_conformances_start
00000000000000000000000000000000
01000000000000007500000000000000
file: /home/lukeh/CVSRoot/apple/build/Ninja-DebugAssert/swift-linux-x86_64/lib/swift/linux/x86_64/libswiftCore.so
dladdr(/home/lukeh/CVSRoot/apple/build/Ninja-DebugAssert/swift-linux-x86_64/lib/swift/linux/x86_64/libswiftCore.so): /home/lukeh/CVSRoot/apple/build/Ninja-DebugAssert/swift-linux-x86_64/lib/swift/linux/x86_64/libswiftCore.so .swift2_protocol_conformances_start
203000000000000010c1000054490200 |
OK, the problem seems to be that the .swift2_protocol_conformances_start symbol created by the linker script is only there for libSwiftCore, not for libFoundation. Perhaps the linker script is not being invoked when building Foundation on Linux. |
integrated in 576e6d9 |
Additional Detail from JIRA
md5: 51dd469c08298ef01774de06da791016
blocks:
duplicates:
Issue Description:
The following code
whilst warned at compile-time to always succeed, fails at runtime, both within Foundation and within a program that links to Foundation. The failure appears to be within_dynamicCastToExistential()’s check for _conformsToProtocols().
Similarly, if I try "NSMutableArray() is NSCoding", it is warned to be true at compile time but aborts at runtime with:
If I replace NSMutableArray() with a class that is defined in my program that links to Foundation, these tests work. Casting directly to NSCoding without going via AnyObject also works.
The text was updated successfully, but these errors were encountered: