-
Notifications
You must be signed in to change notification settings - Fork 7
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
Linking problem with dynamic libs on iOS #1
Comments
Spent some time digging: React statically links with a different libssl version than libtor:$ strings ./RNApp/ios/Pods/OpenSSL-Universal/ios/lib/libssl.a | grep 'OpenSSL 1. $ strings ./openssl/lib/libssl.dylib | grep 'OpenSSL 1.' The crash is while accessing libssl.1.1.dylib`TLSv1_2_enc_data @ 0x11199f3e0. Looking at the asm around the crash, we are in function SSL_CTX_new:
Checking the code of openssl between versions 1.1.1 and 1.0.2, this asm corresponds to the 1.0.2 implementation (the lib checks for "ssl2-md5", "ssl3-md5", "ssl3-sha1" in 1.0.2, whereas in 1.1.1 it checks for "ssl3-md5" and "ssl3-sha1"): So, libtor's code which uses headers for OpenSSL 1.1.1 & calls some symbols from 1.0.2. Now, if we look at the symbol for TLSv1_2_enc_data, we see the opposite, 1.1.1 is the one used:
The TLS_MD_... entries start after 6 adresses in 1.1.1 whereas in 1.0.2 it starts after 6 adresses followed by an int and another address: So we have 1.0.2 code call to data layed out for 1.1.1. So there is some weird interleaving of symbols going both ways. I've spent some time digging in link options to see if there is a way to prevent this but didn't find a solution there. One sad alternative would be to have libtor use the exact same version as the react one, not sure if this is acceptable. By statically linking openssl in libtor we get a different crashI didn't dig into it but maybe it is an easier path, just pasting here for posterity:
It crashes in an unmapped memory location:
Could this one be a different sort of crash? |
Thank you very much for digging @aimxhaisse 👍 |
Ok so I tested calling |
It works when using the same version for both React-Native and go-libtor. |
We have a problem linking the different dynamic libs (libssl, libcrypto, libevent, zlib) required by the go-libtor package with our iOS app (arm64/iphoneos and amd64/iphonesimulator).
We lack time to investigate more and as we say in French: "Better one who knows than ten who are trying to find a solution".
To help find the problem, we have created a separate repo to do sanity checks, there are several branches:
The dynamic libs are the same on every branches, the first two work properly and the last one doesn't work (build ok, linking ok but crash during call to an openssl function). This suggests that the problem is probably due to an incompatibility between the dynamic libs and the go-libtor package.
@Jorropo will maybe continue to investigate on this issue, in any case, he can detail the steps he used to compile the dynamic libs. On my side I took care of:
lipo
. e.g:install_name_tool
. e.g:Note: these steps are not problematic as it works well on both targeted architectures and the linker is able to load the dylibs during runtime.
The following error occurs when pressing the
Test
button which trigger a call to a go-libtor test function (sorted from the bottom to the top of the stack, see left panel):Steps to reproduce the problem on third branch:
make RNApp/node_modules RNApp/ios/Pods framework/Cgo.framework
RNApp/ios/RNApp.xcworkspace
with XCodeThe text was updated successfully, but these errors were encountered: