-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed

Description
When using the TransferClient wrapper for the S3 Client, you must specify a TransferClientConfiguration object to pass into the constructor (there is not a TransferClient constructor that only accepts an S3 client).
The TransferClientConfiguration struct is defined in aws/transfer/TransferClient.h and looks like this:
struct AWS_TRANSFER_API TransferClientConfiguration
{
public:
uint32_t m_uploadBufferCount;
std::shared_ptr< UploadBufferResourceManagerType > m_uploadBufferManager;
};
In the constructor of the TransferClient
itself, it initializes the m_uploadBufferManager
if it is not set, however, it does not initialize the m_uploadBufferCount
:
TransferClient::TransferClient(const std::shared_ptr<Aws::S3::S3Client>& s3Client, const TransferClientConfiguration& config) :
m_s3Client(s3Client),
m_config(config),
m_uploadBufferManager(config.m_uploadBufferManager)
{
if(m_uploadBufferManager == nullptr)
{
m_uploadBufferManager = Aws::MakeShared< FairBoundedResourceManager< UploadBufferResourceType > >(ALLOCATION_TAG, ResourceFactoryFunction, config.m_uploadBufferCount, ResourceWaitPolicy::AT_LEAST_ONE_AVAILABLE);
}
}
As a result, if the user does not initialize the m_uploadBufferCount
themselves, it goes uninitialized and seems to cause problems later.
Here is a reproducible sample:
#include "aws/core/auth/AWSCredentialsProvider.h"
#include "aws/core/utils/memory/stl/AWSAllocator.h"
#include "aws/s3/S3Client.h"
#include "aws/transfer/TransferClient.h"
using namespace Aws::Auth;
using namespace Aws::S3;
using namespace Aws::Transfer;
int main()
{
const char* ALLOCATION_TAG = "CustomerFeedbackManager";
auto s3Client = Aws::MakeShared<S3Client>(ALLOCATION_TAG, AWSCredentials("access_key_id", "secret_key"));
TransferClientConfiguration transferConfig;
//If this line is commented out, the application will generally crash with a memory-related error
//transferConfig.m_uploadBufferCount = 1;
auto s3TransferClient = Aws::MakeShared<TransferClient>(ALLOCATION_TAG, s3Client, transferConfig);
}
In Visual Studio 2013 on Windows, this sample program generates this error:
Debug Assertion Failed
Program: C:\WINDOWS\system32\MSVCP120D.dll
File: C:\Program Files (x86)\Microsoft Visual Studio\12.0\VC\include\xmemory
Line: 439
Expression: invalid null pointer
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
Metadata
Metadata
Assignees
Labels
No labels