Обнаружен свободный () неверный указатель при использовании библиотеки aws-sdk-cpp-sqs

Я пытаюсь использовать экспериментальный SDK, недавно выпущенный Amazon AWS для C ++. Моя цель состоит в том, чтобы моя программа на С ++ получала сообщения из Amazon SQS, поэтому мне нужно сначала установить соединение с SQS. Я новичок в C ++.
Мне удалось скомпилировать программу, но ошибка возникла во время выполнения

Мой код:

#include <iostream> #include <sstream> #include <iterator> #include <algorithm> #include <string.h> #include <unistd.h> #include <aws/core/client/ClientConfiguration.h> #include <aws/core/client/CoreErrors.h> #include <aws/core/auth/AWSCredentialsProviderChain.h> #include <aws/core/utils/json/JsonSerializer.h> #include <aws/core/utils/xml/XmlSerializer.h> #include <aws/sqs/SQSClient.h> #include <aws/sqs/model/CreateQueueRequest.h> #include <aws/sqs/model/ListQueuesRequest.h> #include <aws/sqs/model/DeleteQueueRequest.h> #include <aws/sqs/model/SendMessageRequest.h> #include <aws/sqs/model/ReceiveMessageRequest.h> #include <aws/sqs/model/DeleteMessageRequest.h> #include <aws/sqs/model/GetQueueAttributesRequest.h> #include <aws/sqs/model/SetQueueAttributesRequest.h> #include <aws/sqs/model/AddPermissionRequest.h> #include <aws/sqs/model/RemovePermissionRequest.h> #include <aws/sqs/model/ListDeadLetterSourceQueuesRequest.h> #include <aws/core/utils/Outcome.h> #include <aws/sqs/model/ChangeMessageVisibilityBatchRequestEntry.h> #include <aws/sqs/model/ChangeMessageVisibilityBatchRequest.h> #include <aws/sqs/model/SendMessageBatchRequestEntry.h> #include <aws/sqs/model/SendMessageBatchRequest.h> #include <memory> using namespace Aws::Http; using namespace Aws; using namespace Aws::Auth; using namespace Aws::Client; using namespace Aws::SQS; using namespace Aws::SQS::Model; using namespace Aws::Utils::Json;
int main(int argc, char** argv) {
//Initialize SQS client
ClientConfiguration config;
config.scheme = Scheme::HTTPS;
config.region = Aws::Region::US_EAST_1; std::unique_ptr<SQSClient> sqsClient(new SQSClient(config)); return 0; }

Сообщение об ошибке: free () неверный указатель 0x00007f5a80eeaa80


снимок журнала от valgrind:

1 errors in context 10 of 10: ==22040== Invalid free() / delete / delete[] / realloc() ==22040== at 0x4C2C2BC: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==22040== by 0x5A001BF: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() (in /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21) ==22040== by 0x40154D: Aws::Client::ClientConfiguration::~ClientConfiguration() (ClientConfiguration.h:53) ==22040== by 0x56D730A: Aws::Internal::EC2MetadataClient::EC2MetadataClient(char const*, std::shared_ptr<Aws::Http::HttpClientFactory const>) (in /usr/lib/x86_64-linux-gnu/libaws-cpp-sdk-core.so) ==22040== by 0x56C8541: _ZN9__gnu_cxx13new_allocatorIN3Aws8Internal17EC2MetadataClientEE9constructIS3_IEEEvPT_DpOT0_ (in /usr/lib/x86_64-linux-gnu/libaws-cpp-sdk-core.so) ==22040== by 0x56C8406: _ZNSt16allocator_traitsIN3Aws9AllocatorINS0_8Internal17EC2MetadataClientEEEE12_S_constructIS3_IEEENSt9enable_ifIXsrNS5_18__construct_helperIT_IDpT0_EEE5valueEvE4typeERS4_PS9_DpOSA_ (in /usr/lib/x86_64-linux-gnu/libaws-cpp-sdk-core.so) ==22040== by 0x56C8308: _ZNSt16allocator_traitsIN3Aws9AllocatorINS0_8Internal17EC2MetadataClientEEEE9constructIS3_IEEEDTcl12_S_constructfp_fp0_spcl7forwardIT0_Efp1_EEERS4_PT_DpOS7_ (in /usr/lib/x86_64-linux-gnu/libaws-cpp-sdk-core.so) ==22040== by 0x56C8110: std::_Sp_counted_ptr_inplace<Aws::Internal::EC2MetadataClient, Aws::Allocator<Aws::Internal::EC2MetadataClient>, (__gnu_cxx::_Lock_policy)2>::_Sp_counted_ptr_inplace<>(Aws::Allocator<Aws::Internal::EC2MetadataClient>) (in /usr/lib/x86_64-linux-gnu/libaws-cpp-sdk-core.so) ==22040== by 0x56C7DFD: _ZN9__gnu_cxx13new_allocatorISt23_Sp_counted_ptr_inplaceIN3Aws8Internal17EC2MetadataClientENS2_9AllocatorIS4_EELNS_12_Lock_policyE2EEE9constructIS8_IKS6_EEEvPT_DpOT0_ (in /usr/lib/x86_64-linux-gnu/libaws-cpp-sdk-core.so) ==22040== by 0x56C7C00: _ZNSt16allocator_traitsIN3Aws9AllocatorISt23_Sp_counted_ptr_inplaceINS0_8Internal17EC2MetadataClientENS1_IS4_EELN9__gnu_cxx12_Lock_policyE2EEEEE12_S_constructIS8_IKS5_EEENSt9enable_ifIXsrNSA_18__construct_helperIT_IDpT0_EEE5valueEvE4typeERS9_PSF_DpOSG_ (in /usr/lib/x86_64-linux-gnu/libaws-cpp-sdk-core.so) ==22040== by 0x56C7903: _ZNSt16allocator_traitsIN3Aws9AllocatorISt23_Sp_counted_ptr_inplaceINS0_8Internal17EC2MetadataClientENS1_IS4_EELN9__gnu_cxx12_Lock_policyE2EEEEE9constructIS8_IKS5_EEEDTcl12_S_constructfp_fp0_spcl7forwardIT0_Efp1_EEERS9_PT_DpOSD_ (in /usr/lib/x86_64-linux-gnu/libaws-cpp-sdk-core.so) ==22040== by 0x56C75F8: std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<Aws::Internal::EC2MetadataClient, Aws::Allocator<Aws::Internal::EC2MetadataClient>>(std::_Sp_make_shared_tag, Aws::Internal::EC2MetadataClient*, Aws::Allocator<Aws::Internal::EC2MetadataClient> const&) (in /usr/lib/x86_64-linux-gnu/libaws-cpp-sdk-core.so) ==22040== Address 0x55a3680 is in the BSS segment of /usr/lib/x86_64-linux-gnu/libaws-cpp-sdk-sqs.so ==22040== ==22040== ERROR SUMMARY: 10 errors from 10 contexts (suppressed: 0 from 0)

2

Решение

Я считаю, что проблема связана с поддержкой настраиваемого управления памятью AWS, встроенной в AWS C ++ SDK. По умолчанию, если вы компилируете для общих библиотек, AWS включает настраиваемое управление памятью. Это нормально работало на OSX, но я получил ту же ошибку, что и вы на Ubuntu 14.04

Я вручную удалил строку: add_definitions(-DAWS_CUSTOM_MEMORY_MANAGEMENT) в файле CMakeLists.txt, перекомпилировали и все заработало.

1

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector