I am using aws sdk for linux to transfer file to s3. I have compiled the shared library of aws sdk. Transfer of file fails with bad alloc error so thought to explore the example given by aws-sdk. I am trying to run the example to list the bucket on s3 link . Compiling the application using command:
g++ testingAws.cpp -I . -L . -laws-cpp-sdk-transfer -laws-cpp-sdk-core -laws-cpp-sdk-s3
Everytime the executables terminates with message:
terminate called after throwing an instance of 'std::bad_alloc'
what(): std::bad_alloc
Bad alloc happens when it invokes the function: AwsDoc::S3::PutObject(bucket_name, object_name, clientConfig);
Any suggestion if I am missing something. As well how to debug bad alloc issue.
I tried to list the bucket on my s3 server. Backtrace:
Backtrace: terminate called after throwing an instance of 'std::bad_alloc' what():
std::bad_alloc Thread 1 "a.out" received signal SIGABRT, Aborted.
__pthread_kill_implementation (no_tid=0, signo=6, threadid=140737314626112) at ./nptl/pthread_kill.c:44 44
./nptl/pthread_kill.c: No such file or directory.
(gdb) bt
#0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=140737314626112) at ./nptl/pthread_kill.c:44
#1 __pthread_kill_internal (signo=6, threadid=140737314626112) at ./nptl/pthread_kill.c:78
#2 __GI___pthread_kill (threadid=140737314626112, signo=signo@entry=6) at ./nptl/pthread_kill.c:89
#3 0x00007ffff6b2d476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
#4 0x00007ffff6b137f3 in __GI_abort () at ./stdlib/abort.c:79
#5 0x00007ffff6dd5bbe in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#6 0x00007ffff6de124c in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#7 0x00007ffff6de12b7 in std::terminate() () from /lib/x86_64-linux-gnu/libstdc++.so.6
#8 0x00007ffff6de1518 in __cxa_throw () from /lib/x86_64-linux-gnu/libstdc++.so.6
#9 0x00007ffff6dd57cc in ?? () from /lib/x86_64-linux-gnu/libstdc++.so.6
#10 0x00007ffff6e7ee6f in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_assign(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /lib/x86_64-linux-gnu/libstdc++.so.6
#11 0x00007ffff6e7f22d in std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) () from /lib/x86_64-linux-gnu/libstdc++.so.6
#12 0x000055555555b58d in Aws::S3::Model::PutObjectRequest::SetBucket(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) ()
#13 0x000055555555a78b in AwsDoc::S3::PutObject(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, Aws::Client::ClientConfiguration const&) ()
#14 0x0000000000000000 in ?? ()
(gdb
It's been resolved. I was using header files that were from windows. There was no compilation error so thought everything should work as expectation but later I have taken header files from the Linux machine and that has resolved it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.