aws/aws-sdk-cpp

InitAPI crash in ubuntu 22.04 in latest code

rohitnsb opened this issue · 5 comments

Describe the bug

I built the aws cpp sdk and on initAPI it is crashing
below is the dump

(_Z13dumpBacktraceNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x151) [0x55a437981521]
(_Z10sigHandleri+0x76) [0x55a437983d26]
x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f780e067520]
x86_64-linux-gnu/libc.so.6(pthread_kill+0x12c) [0x7f780e0bb9fc]
x86_64-linux-gnu/libc.so.6(raise+0x16) [0x7f780e067476]
x86_64-linux-gnu/libc.so.6(abort+0xd3) [0x7f780e04d7f3]
x86_64-linux-gnu/libstdc++.so.6(+0xa2b9e) [0x7f780e3f9b9e]
x86_64-linux-gnu/libstdc++.so.6(+0xae20c) [0x7f780e40520c]
x86_64-linux-gnu/libstdc++.so.6(+0xae277) [0x7f780e405277]
x86_64-linux-gnu/libstdc++.so.6(+0xaefa5) [0x7f780e405fa5]
(+0x1798b6f) [0x55a438179b6f]
(aws_client_bootstrap_release+0x40) [0x55a4383557ad]
(_ZN3Aws3Crt2Io15ClientBootstrapD1Ev+0x3b) [0x55a4382c34cb]
(_ZN9__gnu_cxx13new_allocatorIN3Aws3Crt2Io15ClientBootstrapEE7destroyIS4_EEvPT_+0x20) [0x55a4380ef6aa]
(_ZNSt16allocator_traitsISaIN3Aws3Crt2Io15ClientBootstrapEEE7destroyIS3_EEvRS4_PT_+0x27) [0x55a4380ef5af]
(_ZNSt23_Sp_counted_ptr_inplaceIN3Aws3Crt2Io15ClientBootstrapESaIS3_ELN9__gnu_cxx12_Lock_policyE2EE10_M_disp                                                                                                                                                       oseEv+0x3b) [0x55a4380ef0d7]
(_ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_releaseEv+0x32) [0x55a4376ad6f2]
(_ZNSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EED1Ev+0x2b) [0x55a43798b0e9]
(_ZNSt12__shared_ptrIN3Aws3Crt2Io15ClientBootstrapELN9__gnu_cxx12_Lock_policyE2EED1Ev+0x20) [0x55a4380ec2ce]
(_ZNSt10shared_ptrIN3Aws3Crt2Io15ClientBootstrapEED1Ev+0x1c) [0x55a4380ec2ee]
x86_64-linux-gnu/libc.so.6(+0x45495) [0x7f780e06a495]
x86_64-linux-gnu/libc.so.6(on_exit+0) [0x7f780e06a610]
(_Z10sigHandleri+0x94) [0x55a437983d44]
x86_64-linux-gnu/libc.so.6(+0x42520) [0x7f780e067520]
(_ZNSt16_Sp_counted_baseILN9__gnu_cxx12_Lock_policyE2EE10_M_releaseEv+0x65) [0x55a4376ad725]
(_ZN3Aws6Client19ClientConfigurationD1Ev+0x23) [0x55a43782dbd3]
(_ZN3Aws8Internal21AWSHttpResourceClientC2EPKc+0x74) [0x55a438105fec]
(_ZN3Aws8Internal17EC2MetadataClientC1EPKc+0x3a) [0x55a4381070de]
(_ZN9__gnu_cxx13new_allocatorIN3Aws8Internal17EC2MetadataClientEE9constructIS3_JPKcEEEvPT_DpOT0_+0x44) [0x55                                                                                                                                                       a43810fe00]
(_ZNSt16allocator_traitsISaIN3Aws8Internal17EC2MetadataClientEEE9constructIS2_JPKcEEEvRS3_PT_DpOT0_+0x3a) [0                                                                                                                                                       x55a43810faee]
(_ZNSt23_Sp_counted_ptr_inplaceIN3Aws8Internal17EC2MetadataClientESaIS2_ELN9__gnu_cxx12_Lock_policyE2EEC2IJP                                                                                                                                                       KcEEES3_DpOT_+0xac) [0x55a43810f614]
(_ZNSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EEC1IN3Aws8Internal17EC2MetadataClientESaIS6_EJPKcEEERPT_                                                                                                                                                       St20_Sp_alloc_shared_tagIT0_EDpOT1_+0xae) [0x55a43810ef78]
(_ZNSt12__shared_ptrIN3Aws8Internal17EC2MetadataClientELN9__gnu_cxx12_Lock_policyE2EEC1ISaIS2_EJPKcEEESt20_S                                                                                                                                                       p_alloc_shared_tagIT_EDpOT0_+0x4e) [0x55a43810ea32]
(_ZNSt10shared_ptrIN3Aws8Internal17EC2MetadataClientEEC1ISaIS2_EJPKcEEESt20_Sp_alloc_shared_tagIT_EDpOT0_+0x                                                                                                                                                       3b) [0x55a43810e31d]
(_ZSt15allocate_sharedIN3Aws8Internal17EC2MetadataClientESaIS2_EJPKcEESt10shared_ptrIT_ERKT0_DpOT1_+0x3a) [0                                                                                                                                                       x55a43810dbcf]
(_ZN3Aws10MakeSharedINS_8Internal17EC2MetadataClientEJPKcEEESt10shared_ptrIT_ES4_DpOT0_+0x59) [0x55a43810d42                                                                                                                                                       1]
(_ZN3Aws8Internal21InitEC2MetadataClientEv+0x465) [0x55a4381097ac]
(_ZN3Aws7InitAPIERKNS_10SDKOptionsE+0xa44) [0x55a4380eba97]
(_Z10InitAwsSDKv+0x14c) [0x55a4379832ec]
(main+0x2cf) [0x55a43769934f]

Expected Behavior

should not crash

Current Behavior

crash

Reproduction Steps

call InitAPI()

Possible Solution

No response

Additional Information/Context

No response

AWS CPP SDK version used

1.11.293

Compiler and Version used

gcc version 11.4.0

Operating System and version

ubuntu 22.04

I've haven't been able to reproduce the same crash that you are seeing in ubuntu 22.04. Are you calling InitApi multiple times? Can you provide more detailed reproduction steps? I used the following samples and I was able to run without any problems:

main.cpp

#include <iostream>
#include <aws/core/Aws.h>

using namespace std;
using namespace Aws;

int main() {
    Aws::SDKOptions options;
    options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Trace;

    Aws::InitAPI(options);
    {
            std::cout << "Test" <<std::endl;
    }
    Aws::ShutdownAPI(options);
    return 0;
}

CMakeLists.txt

cmake_minimum_required(VERSION 3.22)
project(issue_2913)
set(CMAKE_CXX_STANDARD 20)
find_package(AWSSDK REQUIRED COMPONENTS kms s3 s3-encryption ec2)
add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries(${PROJECT_NAME} ${AWSSDK_LINK_LIBRARIES})

building the sample

cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH="<path to install location>"
cmake --build . --config Debug

I created a new docker and built with below command, still I see the same error

can you check if steps are correct?

git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp
mkdir sd-build
apt-get update
cd sd-build/
apt-get install cmake
apt install zlib1g-dev
apt-get install libssl-dev
apt-get install libcurl4-openssl-dev
cmake ../aws-sdk-cpp -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/usr/lib -DBUILD_ONLY="kms;s3;s3-encryption;ec2;core"
cmake --build . --config Debug

It looks like what you're doing is mostly correct, but I had to add a few things to get the container working. Here is the entire dockerfile that I used to test this. Please let me know if this doesn't work for you:

FROM ubuntu:22.04

#install deps
RUN apt-get update
RUN apt-get install -y git cmake zlib1g-dev libssl-dev libcurl4-openssl-dev build-essential

#clone and build sdk
RUN git clone --depth 1 --recurse-submodules https://github.com/aws/aws-sdk-cpp && \
    cd aws-sdk-cpp && \
    mkdir build && \
    cd build && \
    cmake -DAUTORUN_UNIT_TESTS=OFF -DBUILD_ONLY="kms;s3;s3-encryption;ec2" .. && \
    cmake --build . && \
    cmake --install .

#copy code and build sample application
RUN mkdir sdk-example
COPY CMakeLists.txt sdk-example/CMakeLists.txt
COPY main.cpp sdk-example/main.cpp
RUN cd sdk-example && \
    mkdir build && \
    cd build && \
    cmake .. && \
    cmake --build .

ENTRYPOINT [ "./sdk-example/build/issue_2913" ]

Was ablt to build and init aws SDK with above commands
Not sure what step I missed

Thanks, now it it initing

This issue is now closed. Comments on closed issues are hard for our team to see.
If you need more assistance, please open a new issue that references this one.