-
Notifications
You must be signed in to change notification settings - Fork 1.1k
InitiAPI() getting crashed in C++ AWS Android SDK when consumed in Android apk (Need help) #1067
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
Comments
The stack trace points to this function: void InitializeAWSMemorySystem(MemorySystemInterface& memorySystem)
{
#ifdef USE_AWS_MEMORY_MANAGEMENT
if(AWSMemorySystem != nullptr)
{
AWSMemorySystem->End();
}
AWSMemorySystem = &memorySystem;
AWSMemorySystem->Begin();
#else
AWS_UNREFERENCED_PARAM(memorySystem);
#endif // USE_AWS_MEMORY_MANAGEMENT
} Which is only called if you specify a memory manager in the SDKOptions. So, try disabling that and see if that's the problem. |
Thank you so much @marcomagdy for your inputs. I made sure that no custom options are set. Verified following,
I want to build the Android SDKs for ARMv7s and ARM abi's. Took care of this while building the SDKs too. What am I missing? |
After using this -DCUSTOM_MEMORY_MANAGEMENT=0 and re-generating the Android libraries, the error got changed. Now the application is getting crashed in /data/app/com.example.sample.awstester-euMjrYwTpQTNqxTzSww1zQ==/lib/arm/libaws-cpp-sdk-core.so (_ZNKSt6__ndk18functionIFNS_10shared_ptrIN3Aws5Utils6Crypto22SymmetricCipherFactoryEEEvEEclEv+24) following is the backtrace of crash,
2019-02-14 14:49:21.433 5775-5775/com.example.sample.awstester A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x7 in tid 5775 (sample.awstester) Can anyone help in understanding the cause of this? |
@marcomagdy I read on other GITHub issue post #342. A question was asked 'is anywhere else in your application using libcurl or openssl?' and answer to this was 'if you are, you have to tell the SDK not to via the SDKOptions.'. My application is getting crashed while InitAPI is getting called on Android, the same code works fine on Windows. My application also uses liburl internally for other REST calls. Reading this post, I modified following in my code, but no luck, HttpOptions httpOptions; CryptoOptions cryptoOptions; sdkOptions.cryptoOptions = cryptoOptions; I added 'curl_global_init(CURL_GLOBAL_ALL);' where I am using the libCurl library calls in other area of my application. |
Make Aws::InitAPI(..) the first thing your application calls when it starts. And similarly Aws::ShutdownAPI() the last thing your application calls. In other words, don't call init right before you need to call some AWS functionality. Do it at the very beginning. |
Thank you @marcomagdy . The calls of Aws::InitAPI(..) is the first to be called in my C++ library and Aws::ShutdownAPI() the last one. Initialization of classes which uses libCurl is after the AWS initialization. |
The SDK also initializes the crypto libs (in addition to libcurl). It should be called early in your application not just your library. |
@marcomagdy Thanks again. I might be writing too much, but its just to help understand the details. Application is divided in 3 layers,
The very first call I make to my static lib project is to initialize the AWS using InitAPI(..) method and till then nothing is instantiated from my static library project. Once its initialized, I make call to APIs like authenticateUser(...), listS3Bucket(...) of my library. Somehow, everything works fine on Windows, but Android its crashing. So here's how I have designed and implemented entire application:
Did you meant that the libCurl is internally initializing or using OpenSSL libraries? Just For your knowledge, the intention behind having this architecture is to avoid repetitive business logic on multiple platforms. |
I don't know much about the SDK, but can you try setting the following option?
To see what happens if that if statement is not entered. |
@martinkbrown I already tried setting up the value to nullptr just considering if by default it's holding some value then this would reset it back. But no luck. |
@marcomagdy : Further to this, today I tried by removing entire libCurl dependency from my project and rebuilding the application, but same place its getting crashed still. #00 pc 000c665c /data/app/com.example.sample.awstester-sSm2mcRoRNMwMUssrRyNQw==/lib/arm/libaws-cpp-sdk-core.so (_ZNKSt6__ndk18functionIFNS_10shared_ptrIN3Aws5Utils6Crypto22SymmetricCipherFactoryEEEvEEclEv+24) Anything you can help in? |
As suggested by @marcomagdy I made changes in my application to make the 'Aws::InitAPI(sdkOptions);' at the very beginning before making any call (be it AWS or any other library) and the call got succeeded. In my application I was using making the call to get the user signed-in to Azure AD using Microsoft's IDP log-in page and then was initializing the AWS library. So conclusion is, 'InitAPI' has to be called at very beginning of application launch and 'ShutdownAPI' just before closure of application. P.S. Thanks @marcomagdy :) |
Uh oh!
There was an error while loading. Please reload this page.
While executing the Aws::InitAPI(Aws::SDKOptions) on Android the application is getting crashed.
Same code works fine for Windows.
I am simplifying the explanation by mentioning the exact steps I followed.
Note: The SWIG part for generating the JNI Wrapper is test OK and its working fine. SO you can ignore that part while analysis.
Following are the steps that I have followed to create my own cross platform static library project that consumes required AWS SDK libraries.
Following is what I did for Android on top of above steps:
Following is what I did for Windows on top of steps mentioned on first bullet:
Why is Android failing to initialize? Have I missed anything while building the Android SDK libraries?
What platform/OS are you using?
Android
What compiler are you using? what version?
Clang 5.0
What's your CMake arguments?
cmake -DCUSTOM_MEMORY_MANAGEMENT=0 -DBUILD_ONLY="cognito-identity;core;identity-management;s3;sts" -DTARGET_ARCH=ANDROID -DANDROID_ABI=armeabi-v7a ~/git/aws-sdk-cpp
Can you provide a TRACE level log? (sanitize any sensitive information)
--------- beginning of crash
2019-03-01 17:10:23.029 22640-22640/com.example.sample.awstester A/libc: Fatal signal 11 (SIGSEGV), code 1, fault addr 0x1 in tid 22640 (sample.awstester)
2019-03-01 17:10:23.078 22718-22718/? E/propClient: PropClient failed to load
2019-03-01 17:10:23.110 22719-22719/? I/crash_dump32: obtaining output fd from tombstoned
2019-03-01 17:10:23.111 1191-1191/? I//system/bin/tombstoned: received crash request for pid 22640
2019-03-01 17:10:23.113 22719-22719/? I/crash_dump32: performing dump of process 22640 (target tid = 22640)
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: Build fingerprint: 'Verizon/hero2qltevzw/hero2qltevzw:8.0.0/R16NW/G935VVRS8CRK2:user/release-keys'
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: Revision: '15'
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: ABI: 'arm'
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: pid: 22640, tid: 22640, name: sample.awstester >>> com.example.sample.awstester <<<
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x1
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: Cause: null pointer dereference
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: r0 00000001 r1 00000001 r2 d13ea1a4 r3 00000041
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: r4 ef9c9234 r5 00000000 r6 00000000 r7 ffd0d7f0
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: r8 0000004a r9 eef74000 sl ffd0d850 fp ffd0d548
2019-03-01 17:10:23.114 22719-22719/? A/DEBUG: ip d13dcbe4 sp ffd0d540 lr d102ddbc pc d114eac8 cpsr 600f0010
2019-03-01 17:10:23.153 22719-22719/? A/DEBUG: backtrace:
2019-03-01 17:10:23.153 22719-22719/? A/DEBUG: #00 pc 001f9ac8 /data/app/com.example.sample.awstester-K9sGZKePIlELp6UedDMOPw==/lib/arm/libaws-cpp-sdk-core.so (_ZN3Aws5Utils6Memory25InitializeAWSMemorySystemERNS1_21MemorySystemInterfaceE+84)
2019-03-01 17:10:23.153 22719-22719/? A/DEBUG: #1 pc 000d8db8 /data/app/com.example.sample.awstester-K9sGZKePIlELp6UedDMOPw==/lib/arm/libaws-cpp-sdk-core.so (_ZN3Aws7InitAPIERKNS_10SDKOptionsE+44)
2019-03-01 17:10:23.153 22719-22719/? A/DEBUG: #2 pc 00069b95 /data/app/com.example.sample.awstester-K9sGZKePIlELp6UedDMOPw==/lib/arm/libAWSServicesProviderD.so (_ZN19AWSServicesProviderC1Ev+56)
2019-03-01 17:10:23.153 22719-22719/? A/DEBUG: #3 pc 000695f5 /data/app/com.example.sample.awstester-K9sGZKePIlELp6UedDMOPw==/lib/arm/libAWSServicesProviderD.so (Java_com_testdomain_AWSServicesProviderWrapper_AWSServicesProviderWrapperJNI_new_1AWSServicesProvider+40)
The text was updated successfully, but these errors were encountered: