Skip to content

Segmentation fault at Aws::Utils::Threading::ReaderWriterLock::LockReader () #1716

Closed
@kaushikd153

Description

@kaushikd153

Confirm by changing [ ] to [x] below:

Platform/OS/Hardware/Device

RHEL 8.0 ,GCC 8.4

Describe the question

Program received signal SIGSEGV, Segmentation fault.
0x00007ffff76f0555 in std::__atomic_base::operator++ (this=this@entry=0x178) at /usr/include/c++/8/bits/atomic_base.h:295
295 operator++() noexcept
Got below backtrace using GDB.

(gdb) bt
#0 0x00007ffff76f0555 in std::__atomic_base::operator++ (this=this@entry=0x178) at /usr/include/c++/8/bits/atomic_base.h:295
#1 Aws::Utils::Threading::ReaderWriterLock::LockReader (this=this@entry=0x178)
at /code_v8u1/aws-sdk/aws-sdk-1.8/aws-cpp-sdk-core/source/utils/threading/ReaderWriterLock.cpp:35
#2 0x00007ffff7700add in Aws::Utils::Threading::ReaderLockGuard::ReaderLockGuard (rwl=..., this=)
at /code_v8u1/aws-sdk/aws-sdk-1.8/aws-cpp-sdk-core/include/aws/core/utils/threading/ReaderWriterLock.h:77
#3 Aws::Config::ConfigAndCredentialsCacheManager::GetConfig (this=this@entry=0x0, profileName="default", key="max_attempts")
at /code_v8u1/aws-sdk/aws-sdk-1.8/aws-cpp-sdk-core/source/config/AWSProfileConfigLoader.cpp:420
#4 0x00007ffff770f567 in Aws::Config::GetCachedConfigValue (key="max_attempts") at /usr/include/c++/8/bits/unique_ptr.h:345
#5 0x00007ffff77108ef in Aws::Client::ClientConfiguration::ClientConfiguration (this=0x5555557e6ca8) at /usr/include/c++/8/ext/new_allocator.h:79
#6 0x0000555555562b57 in OFS_Client_S3_Impl::OFS_Client_S3_Impl (this=0x5555557e6ad0) at ../drivers/s3/Client_S3_Impl.h:20
#7 0x000055555556171f in OFS_Client::createInstance (type="S3") at OFS_Client.cpp:36
#8 0x000055555556ba94 in test_s3_credential (src=0x7fffffffd655 "s3://ap-south-1/dev-s3") at mount.cpp:268
#9 0x000055555556e32e in mount_ofs (argc=5, argv=0x7fffffffd2e8) at mount.cpp:591
#10 0x000055555556e56b in main (argc=5, argv=0x7fffffffd2e8) at main.cpp:22

The issue is with one binary ( for the proprietary product of the company, I am working for ) which is getting compiled using aws-sdk-cpp generated shared libs. The code used for generating the binary is doing fine with shared libs from aws-sdk-cpp version 1.7.324 and earlier. But I am getting issue when I compiled the binary using shared libs from aws-sdk-cpp version 1.7.325 or later. I find the issue persisting when using shared libs from aws-sdk-cpp version 1.8 and 1.9 too.

Usage: mount.s3 S3_URL MOUNT_POINT -o OPTIONS

mount.s3 s3://ap-south-1/dev-s3 /tmp/ws_5c318bb4-61c0-486f-baa0-f9fab21f3af2 -o username=******,test_s3_credential

Enter the KEYDATA : data input

Logs/output
output starts***********
[07-19 17:13:28][20773 - mount.cpp:531]src=s3://ap-south-1/dev-s3, tgt= /tmp/ws_f6750a40-6ae2-412e-9a11-7e7bbd673ecc, opt=username=AKIAVFEEXDW4RFIWRHPC,test_s3_credential
[07-19 17:13:28][20773 - mount.cpp:235]region=ap-south-1, bucket=dev-s3, endpoint=(null)
[07-19 17:13:28][20773 - mount.cpp:249]Please input key data:
data input
[07-19 17:13:40][20773 - mount.cpp:254]S3_KEY_DATA:*******************
[07-19 17:13:40][20773 - mount.cpp:265] region=ap-south-1, bucket=dev-s3, endpoint=(null), keyId=AKIAVFEEXDW4RFIWRHPC, keyData= data input
output ends***********

I will not be able to paste the exact code of the product but trying to provide reference/snippet to contact point to AWS api calls as much as possible.

int main(int argc, char *argv[])
{
************************
if(strcmp(p, "mount.s3")==0)
{
return mount_ofs(argc, argv);
}
***************************
}

int mount_ofs(int argc, char *argv[])
{
**********************
if(get_option("test_s3_credential")!=NULL) {
return test_s3_credential(src);
}
**********************
}

static int test_s3_credential(char *src)
{
***********************
LOG0("kas region=%s, bucket=%s, endpoint=%s, keyId=%s, keyData=%s", region, bucket, endpoint,keyId,keyData);
OFS_Client *s3 = OFS_Client::createInstance("S3");
***********************
return 0;
}

OFS_Client* OFS_Client::createInstance(const std::string& type)
{
if(type=="S3")
{
return new OFS_Client_S3_Impl();
}
return NULL;
}

Then the flow is going to Client_S3_Impl.h

Client_S3_Impl.h

#ifndef _CLIENT_S3_IMPL_H
#define _CLIENT_S3_IMPL_H
#include
#include
#include <aws/core/Aws.h>
#include <aws/s3/S3Client.h>
#include <aws/core/auth/AWSCredentialsProviderChain.h>
#include <aws/core/utils/ratelimiter/DefaultRateLimiter.h>
#include "OFS_Client.h"
using namespace Aws::Http;
using namespace Aws::Client;
using namespace Aws::S3;
using namespace Aws::S3::Model;
using namespace Aws::Utils;

class OFS_Client_S3_Impl : public OFS_Client
{
private:


    Aws::SDKOptions m_options;
    ClientConfiguration m_config;
    ClientConfiguration m_configForFile;
    AWSCredentials m_cred;

public:


    std::shared_ptr<S3Client> getClient();
    virtual int mount(OFS_Vol** vol, const std::string& dev, const std::string& options=NULL);

};

I believe from here due to instance of class ClientConfiguration, the flow is going to Aws::Client::ClientConfiguration::ClientConfiguration
and subsequently segmentation fault occurred atlast(or after) Aws::Utils::Threading::ReaderWriterLock::LockReader()

Metadata

Metadata

Assignees

No one assigned

    Labels

    closing-soonThis issue will automatically close in 4 days unless further comments are made.guidanceQuestion that needs advice or information.needs-reproductionThis issue needs reproduction.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions