aws / aws-sdk-cpp

AWS SDK for C++
Apache License 2.0
1.96k stars 1.05k forks source link

Cannot build sdk on a Amazon Linux 2023 based Container after 1.11.211 Version Tag #2862

Closed davehines closed 7 months ago

davehines commented 7 months ago

Describe the bug

When I try to build the SDK after the 1.11.211 tag , the build fails on one of the tests with the following error

/usr/include/c++/11/bits/shared_ptr_base.h:979: std::__shared_ptr_access<_Tp, _Lp, <anonymous>, <anonymous> >::element_type& std::__shared_ptr_access<_Tp, _Lp, <anonymous>, <anonymous> >::operator*() const [with _Tp = Aws::Http::ServiceSpecificParameters; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic; bool <anonymous> = false; bool <anonymous> = false; std::__shared_ptr_access<_Tp, _Lp, <anonymous>, <anonymous> >::element_type = Aws::Http::ServiceSpecificParameters]: Assertion '_M_get() != nullptr' failed.

If I build with run unit tests turned off -DAUTORUN_UNIT_TESTS=OFF the build succeeds , but my simple application fails with the exact same error

Expected Behavior

Test should run and pass

Current Behavior

Error /usr/include/c++/11/bits/shared_ptr_base.h:979: std::__shared_ptr_access<_Tp, _Lp, <anonymous>, <anonymous> >::element_type& std::__shared_ptr_access<_Tp, _Lp, <anonymous>, <anonymous> >::operator*() const [with _Tp = Aws::Http::ServiceSpecificParameters; __gnu_cxx::_Lock_policy _Lp = __gnu_cxx::_S_atomic; bool <anonymous> = false; bool <anonymous> = false; std::__shared_ptr_access<_Tp, _Lp, <anonymous>, <anonymous> >::element_type = Aws::Http::ServiceSpecificParameters]: Assertion '_M_get() != nullptr' failed.

image of relevant part stack from gdb from our test application which gives the image

Reproduction Steps

cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/AWS_XXX -DCMAKE_BUILD_TYPE=Release - -DBUILD_ONLY="access-management;cognito-identity;core;dynamodb;ecs;events;iam;logs;s3;sqs;transfer;states;sts;xray" make

Wait for SDK to build and run tests

Possible Solution

No response

Additional Information/Context

No response

AWS CPP SDK version used

= 1.11.212

Compiler and Version used

gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2)

Operating System and version

Amazon Linux 2023

jmklix commented 7 months ago

I've tried reproducing this, but I can't seem to get the same error that you're getting. Can you reproduce this in a docker container? If so can you reply with the dockerfile and any additional steps you take to reproduce this error?

davehines commented 7 months ago

The issue seems to be when I try to build within an rpmbuild SPEC file , the simple build on the container works . I'm currently trying to isolate this at the moment

davehines commented 7 months ago

The issue I'm having appears to be that building as an RPM on AL 2023 turns on a lot of security hardening ( which is desirable for me ) The flags from rpm --eval %{optflags}

which evaluate to -O2 -ftree-vectorize -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64-v2 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection

If I remove -D_GLIBCXX_ASSERTIONS The error no longer occurs , though I get warnings that it isn't defined.

or if I just define that as part of CMAKE_CXX_FLAGS the issue appears in the normal make . ie not using rpm build

cmake .. -DZLIB_INCLUDE_DIR=/usr/include -DCMAKE_INSTALL_PREFIX=/usr/local/AWS_LATEST/ -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY="access-management;cognito-identity;core;dynamodb;ecs;events;iam;logs;s3;sqs;transfer;states;sts;xray" -DCMAKE_CXX_FLAGS="-O2 -D_GLIBCXX_ASSERTIONS"

The Docker file for the container I'm using is shown below I'm shelling on to the container , cloning the repo , running cmake , and then make

FROM amazonlinux:2023
RUN yum install  -y awscli gcc-c++ openssl-libs tar  curl-devel git cmake zlib-devel rpm-build vim binutils libdrm-devel mesa-libGLU-devel zlib-devel openssl-devel
RUN yum install -y perl ninja-build rpmdevtools rpmlint
RUN yum install -y sqlite-devel libtiff-devel
RUN yum install -y gdb

RUN adduser ec2-user
USER ec2-user
davehines commented 7 months ago

Dockerfile which produces the error, build and run

FROM amazonlinux:2023
RUN yum install  -y awscli gcc-c++ openssl-libs tar  curl-devel git cmake zlib-devel rpm-build vim binutils libdrm-devel mesa-libGLU-devel zlib-devel openssl-devel
RUN yum install -y perl ninja-build rpmdevtools rpmlint
RUN yum install -y sqlite-devel libtiff-devel
RUN yum install -y gdb

RUN adduser ec2-user
USER ec2-user
WORKDIR ~/
RUN echo -e  "#!/bin/sh \n git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp aws-sdk-cpp && cd aws-sdk-cpp && mkdir RELEASE && cd RELEASE && cmake .. -DZLIB_INCLUDE_DIR=/usr/include -DCMAKE_INSTALL_PREFIX=/usr/local/AWS_LATEST/ -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY=\"access-management;cognito-identity;core;dynamodb;ecs;events;iam;logs;s3;sqs;transfer;states;sts;xray\" -DCMAKE_CXX_FLAGS=\"-O2 -D_GLIBCXX_ASSERTIONS\" && make " > command
RUN chmod 777 ./command
CMD ["./command"]
sbiscigl commented 7 months ago

the issue here is _GLIBCXX_ASSERTIONS being supplied to the compiler. It looks like it found some UB we have, working at addressing it. If you remove that flag you should see it work as expected. will work at fixing it.

sbiscigl commented 7 months ago

should be fixed now

davehines commented 7 months ago

Thank you will check today

davehines commented 7 months ago

This now builds fine for us :)

github-actions[bot] commented 7 months ago

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.