-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Seg fault in call to InitAPI #342
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
Does your code initialize OpenSSL or libcurl anywhere else? Sent from my iPhone
|
Not to my knowledge. Should it? |
Actually, I now see that my code is getting called twice, which means that those libraries are getting initialized elsewhere, in the first call to InitAPI, which does succeed. I didn't expect my code to get called twice; there may be a bug on my end. |
Would you mind sharing your build, execution, and debug (for the android app itself) setup? Android debugging is something I've struggled with (pretty much log-only so far) and the fact that you're sitting in LLDB has me very jealous. |
No, if you are, you have to tell the SDK not to via the SDKOptions. Sent from my iPhone
|
I now see that the documentation for ShutdownAPI states, "Do not call any other SDK methods after calling ShutdownAPI." I'm calling InitAPI after a call to ShutdownAPI; I think this is my bug. @bretambrose I'm not sure exactly what information you're looking for regarding my development setup, but here's some info: My OS is OS X El Capitan. Android Studio 2.2.2 and the default tools it uses (Gradle, LLDB) handle most things related to build, execution, and debug. I'm running the app on a Genymotion 2.8.0 emulator. |
It's complicated. As long as you can guarantee that all memory and modules are deleted before calling shutdownAPI, it should be fine. The other day, I actually accidentally had a segfault in my own code due to this. In general non-trivial statics and long lived memory on the heap is your enemy, and will cause results like this. Sent from my iPhone
|
I have a similar situation but only happen in a specific context. I'm trying to hook up S3 uploading feature in Unreal Engine 4 but segmentation fault always comes to me when executing My configurations:
gdb output with backtrace
|
NO_ENCRYPTION means you are supplying your own crypto code via the factories in Aws::CryptoOptions and we will not attempt to compile the platform defaults (this is largely for playstation and xbox or other embedded platforms where they may want to do hardware level crypto). If libcrypto, commoncrypto or msft cng, are on the platform you are building against, leave that option on unless you have a very special use case. If you do turn it off, you are responsible for providing your own implementation via the CryptoOptions.
…Sent from my iPhone
On Jan 29, 2017, at 11:03 AM, Ray Chen ***@***.***> wrote:
I have a similar situation but only happen in a specific context. I'm trying to hook up S3 uploading feature in Unreal Engine 4 but segmentation fault always comes to me when executing Aws::InitAPI call. What confuses me is that the exact same code works on Unreal Engine 4 for Mac and Linux (using aws-doc-sdk-examples) except for Unreal Engine 4 for Linux. Also, when I compiled for -DNO_ENCRYPTION=ON, the unit test for sdk fails at AWSAuthV4SignerTest. Is there something you can point me that I should look into? Thanks in advance. @JonathanHenson
My configurations:
Ubuntu 16.04 LTS
libssl-dev: 1.0.2g-1ubuntu4.5
Unreal Engine 4.14
gdb output with backtrace
Thread 1 "UE4Editor" received signal SIGSEGV, Segmentation fault.
0x00000000029ccea0 in ?? ()
(gdb)
(gdb) bt
#0 0x00000000029ccea0 in ?? ()
#1 0x00007fff8468e39d in std::function<std::shared_ptr<Aws::Utils::Crypto::SymmetricCipherFactory> ()>::operator()() const ()
from /usr/local/lib/libaws-cpp-sdk-core.so
#2 0x00007fff8468de04 in Aws::InitAPI(Aws::SDKOptions const&) ()
from /usr/local/lib/libaws-cpp-sdk-core.so
#3 0x00007fff849c6edd in UAWSClient::UploadFileToS3 (FileName=...,
FileAbsolutePath=...)
at /home/ray/YSProjects/TestBed/Source/TestBed/Private/AWSClient.cpp:25
#4 0x00007fff849ca169 in UAWSClient::execUploadFileToS3 (
this=<optimized out>, Stack=..., Z_Param__Result=<optimized out>)
at ../../../YSProjects/TestBed/Source/TestBed/Public/AWSClient.h:19
#5 0x00007ffff66ecf22 in UFunction::Invoke (this=<optimized out>,
Obj=<optimized out>, Stack=..., Z_Param__Result=<optimized out>)
at /home/ray/UnrealEngine/Engine/Source/Runtime/CoreUObject/Private/UObject/Class.cpp:4474
#6 0x00007ffff6842237 in UObject::CallFunction (this=0x7fff89218fc0,
Stack=..., Z_Param__Result=0x7fffffffa830, Function=<optimized out>)
at /home/ray/UnrealEngine/Engine/Source/Runtime/CoreUObject/Private/UObject/ScriptCore.cpp:700
#7 0x00007ffff684b3f5 in FFrame::Step (this=0x7fffffffa950,
Z_Param__Result=0x7fffffffa830, Context=<optimized out>)
at /home/ray/UnrealEngine/Engine/Source/Runtime/CoreUObject/Private/UObject/---Typ------Type <return> to continu-----Type <r---Type <return> to continue, or q <return> to quit---
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
as for your segfault, is anywhere else in your application using libcurl or openssl?
…Sent from my iPhone
On Jan 29, 2017, at 11:03 AM, Ray Chen ***@***.***> wrote:
I have a similar situation but only happen in a specific context. I'm trying to hook up S3 uploading feature in Unreal Engine 4 but segmentation fault always comes to me when executing Aws::InitAPI call. What confuses me is that the exact same code works on Unreal Engine 4 for Mac and Linux (using aws-doc-sdk-examples) except for Unreal Engine 4 for Linux. Also, when I compiled for -DNO_ENCRYPTION=ON, the unit test for sdk fails at AWSAuthV4SignerTest. Is there something you can point me that I should look into? Thanks in advance. @JonathanHenson
My configurations:
Ubuntu 16.04 LTS
libssl-dev: 1.0.2g-1ubuntu4.5
Unreal Engine 4.14
gdb output with backtrace
Thread 1 "UE4Editor" received signal SIGSEGV, Segmentation fault.
0x00000000029ccea0 in ?? ()
(gdb)
(gdb) bt
#0 0x00000000029ccea0 in ?? ()
#1 0x00007fff8468e39d in std::function<std::shared_ptr<Aws::Utils::Crypto::SymmetricCipherFactory> ()>::operator()() const ()
from /usr/local/lib/libaws-cpp-sdk-core.so
#2 0x00007fff8468de04 in Aws::InitAPI(Aws::SDKOptions const&) ()
from /usr/local/lib/libaws-cpp-sdk-core.so
#3 0x00007fff849c6edd in UAWSClient::UploadFileToS3 (FileName=...,
FileAbsolutePath=...)
at /home/ray/YSProjects/TestBed/Source/TestBed/Private/AWSClient.cpp:25
#4 0x00007fff849ca169 in UAWSClient::execUploadFileToS3 (
this=<optimized out>, Stack=..., Z_Param__Result=<optimized out>)
at ../../../YSProjects/TestBed/Source/TestBed/Public/AWSClient.h:19
#5 0x00007ffff66ecf22 in UFunction::Invoke (this=<optimized out>,
Obj=<optimized out>, Stack=..., Z_Param__Result=<optimized out>)
at /home/ray/UnrealEngine/Engine/Source/Runtime/CoreUObject/Private/UObject/Class.cpp:4474
#6 0x00007ffff6842237 in UObject::CallFunction (this=0x7fff89218fc0,
Stack=..., Z_Param__Result=0x7fffffffa830, Function=<optimized out>)
at /home/ray/UnrealEngine/Engine/Source/Runtime/CoreUObject/Private/UObject/ScriptCore.cpp:700
#7 0x00007ffff684b3f5 in FFrame::Step (this=0x7fffffffa950,
Z_Param__Result=0x7fffffffa830, Context=<optimized out>)
at /home/ray/UnrealEngine/Engine/Source/Runtime/CoreUObject/Private/UObject/---Typ------Type <return> to continu-----Type <r---Type <return> to continue, or q <return> to quit---
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Not that I'm aware of. The AWS part is the only place from my application that uses libcurl and openssl. |
looks like you are segfaulting in initialization because you have not built the crypto layer. Is this running on a build that has NO_ENCRYPTION turned on? If so, that's your problem.
…Sent from my iPhone
On Jan 29, 2017, at 11:36 AM, Ray Chen ***@***.***> wrote:
Not that I'm aware of. The AWS part is the only place that needs libcurl and openssl.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Sorry I should have clarify that. The segfault wasn't resulting from enabling NO_ENCRYPTION. I was using |
any chance you can upload some valgrind output?
…Sent from my iPhone
On Jan 29, 2017, at 12:40 PM, Ray Chen ***@***.***> wrote:
Sorry I should have clarify that. The segfault wasn't resulting from enabling NO_ENCRYPTION. I was using cmake -DBUILD_ONLY="s3" <path-to-sdk-source> across platforms, which works for all the other except Unreal Linux. NO_ENCRYPTION is what I experiment to see if that's related.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Sure, I haven't used valgrind before but I'll give it a try. Unrelated question, sometime when I
|
This valgrind output captures as soon as the
|
This should not be possible without you explicitly setting one of the callback functions in CryptoOptions, could you upload the full text of UAWSClient::UploadfileToS3 so I can have a look? |
Sure
|
key_name is going to have its allocator swapped out from under it, when you call InitAPI(). You shouldn't use any thing from one of our header files before you call InitAPI(). Also InitAPI needs to go way way up the chain inside int main(char** argv, int argv) Also, as written, this will segfault at ShutdownAPI anyways, because ShutdownAPI will be called before clientConfig, s3_client, and the rest gets cleaned up. You would need scoping brackets to make that work. |
For reference you could have a look at the AWS_Lmbr components in the Lumberyard Engine. |
Just ran into this exact symptom (same stack as the OP), on the 2nd call to InitAPI. Is it OK to call InitAPI after ShutdownAPI, or not? That is, as long as every InitAPI has a corresponding ShutdownAPI that is called before the next @InitAPI, should that work? FWIW, it seems to work fine on Windows, but not linux. |
in theory, it would work, but you should not do it. Put InitAPI in the entry point of your application as early as possible. a.) Its expensive. b.) it manipulates global state. c.) on linux it alters state of openssl and libcurl. d.) Nothing guarantees the compiler does not change the ordering of your calls.
e.) That will not work in a multi-threaded scenario.
…Sent from my iPhone
On Jan 30, 2017, at 5:36 PM, Andy Dennie ***@***.***> wrote:
Just ran into this exact symptom (same stack as the OP), on the 2nd call to InitializeAPI. Is it OK to call InitializeAPI after ShutdownAPI, or not? That is, as long as every InitializeAPI has a corresponding ShutdownAPI that is called before the next InitializeAPI, should that work?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.
|
also, that will shutdown the logging thread. It will likely not start back up on the next call to InitAPI()
…Sent from my iPhone
On Jan 30, 2017, at 5:36 PM, Andy Dennie ***@***.***> wrote:
Just ran into this exact symptom (same stack as the OP), on the 2nd call to InitializeAPI. Is it OK to call InitializeAPI after ShutdownAPI, or not? That is, as long as every InitializeAPI has a corresponding ShutdownAPI that is called before the next InitializeAPI, should that work?
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub, or mute the thread.
|
It turns out that the segfault is resulting from |
Closing |
Hey @JonathanHenson : You mentioned in one of your post 'you have to tell the SDK not to via the SDKOptions.'. My application is getting crashed while InitAPI is getting called on Android. I also use licurl internally for other REST calls. How to tell AWS SDK not to initialize the libcurl again?? BTW the same code works fine on Windows. |
As soon as my code calls InitAPI, it hits a seg fault. This is my code, which just tries to call InitAPI and ShutdownAPI with default options:
This is the stack trace of the crash:
The text was updated successfully, but these errors were encountered: