Fatal error when destroying S3Client at shutdown
Describe the bug
When a S3Client is destroyed as part of process shutdown, I get this crash:
Fatal error condition occurred in /home/conda/feedstock_root/build_artifacts/aws-c-common_1667631740203/work/source/allocator.c:209: allocator != ((void *)0)
Exiting Application
No call stack information available
Thread 1 "arrow-s3fs-test" received signal SIGABRT, Aborted.
The gdb backtrace is as follows:
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1 0x00007ffff1d4f859 in __GI_abort () at abort.c:79
#2 0x00007ffff22ff2ce in aws_fatal_assert () from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-c-common.so.1
#3 0x00007ffff22fd8c7 in aws_mem_release () from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-c-common.so.1
#4 0x00007ffff2309101 in cJSON_Delete () from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-c-common.so.1
#5 0x00007ffff23090ea in cJSON_Delete () from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-c-common.so.1
#6 0x00007ffff2343d43 in s_endpoints_ruleset_destroy () from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-c-sdkutils.so.1.0.0
#7 0x00007ffff23149cd in aws_ref_count_release () from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-c-common.so.1
#8 0x00007ffff2346083 in aws_endpoints_ruleset_release () from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-c-sdkutils.so.1.0.0
#9 0x00007ffff2340e73 in s_endpoints_rule_engine_destroy () from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-c-sdkutils.so.1.0.0
#10 0x00007ffff23149cd in aws_ref_count_release () from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-c-common.so.1
#11 0x00007ffff23420f3 in aws_endpoints_rule_engine_release () from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-c-sdkutils.so.1.0.0
#12 0x00007ffff260ca2d in Aws::Crt::Endpoints::RuleEngine::~RuleEngine() () from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-crt-cpp.so
#13 0x00007ffff2c4b61a in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release() ()
from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-cpp-sdk-s3.so
#14 0x00007ffff2c5373c in Aws::S3::S3Client::~S3Client() () from /home/antoine/mambaforge/envs/pyarrow/lib/libaws-cpp-sdk-s3.so
#15 0x00007ffff6a6cdea in arrow::fs::(anonymous namespace)::S3Client::~S3Client (this=0x555555962330, __in_chrg=<optimized out>)
at /home/antoine/arrow/dev/cpp/src/arrow/filesystem/s3fs.cc:610
#16 0x00007ffff6a6df0d in std::_Destroy<arrow::fs::(anonymous namespace)::S3Client> (__pointer=0x555555962330)
at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.1.0/bits/stl_construct.h:151
#17 0x00007ffff6a6dc20 in std::allocator_traits<std::allocator<void> >::destroy<arrow::fs::(anonymous namespace)::S3Client> (__p=0x555555962330)
at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.1.0/bits/alloc_traits.h:648
#18 0x00007ffff6a6d6e7 in std::_Sp_counted_ptr_inplace<arrow::fs::(anonymous namespace)::S3Client, std::allocator<void>, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x555555962320) at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.1.0/bits/shared_ptr_base.h:613
#19 0x00007ffff53459d9 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x555555962320)
at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.1.0/bits/shared_ptr_base.h:346
#20 0x00007ffff5348e43 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (this=0x555555a31e28, __in_chrg=<optimized out>)
at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.1.0/bits/shared_ptr_base.h:1071
#21 0x00007ffff6a5426a in std::__shared_ptr<arrow::fs::(anonymous namespace)::S3Client, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (this=0x555555a31e20,
__in_chrg=<optimized out>) at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.1.0/bits/shared_ptr_base.h:1524
#22 0x00007ffff6a54286 in std::shared_ptr<arrow::fs::(anonymous namespace)::S3Client>::~shared_ptr (this=0x555555a31e20, __in_chrg=<optimized out>)
at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.1.0/bits/shared_ptr.h:175
#23 0x00007ffff6a6824e in arrow::fs::(anonymous namespace)::RegionResolver::~RegionResolver (this=0x555555a319d0, __in_chrg=<optimized out>)
at /home/antoine/arrow/dev/cpp/src/arrow/filesystem/s3fs.cc:858
#24 0x00007ffff6a6d610 in std::_Sp_counted_ptr<arrow::fs::(anonymous namespace)::RegionResolver*, (__gnu_cxx::_Lock_policy)2>::_M_dispose (this=0x555555a58090)
at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.1.0/bits/shared_ptr_base.h:428
#25 0x00007ffff53459d9 in std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release (this=0x555555a58090)
at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.1.0/bits/shared_ptr_base.h:346
#26 0x00007ffff5348e43 in std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count (
this=0x7ffff78298f8 <arrow::fs::(anonymous namespace)::RegionResolver::DefaultInstance()::instance+8>, __in_chrg=<optimized out>)
at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.1.0/bits/shared_ptr_base.h:1071
#27 0x00007ffff6a549d6 in std::__shared_ptr<arrow::fs::(anonymous namespace)::RegionResolver, (__gnu_cxx::_Lock_policy)2>::~__shared_ptr (
this=0x7ffff78298f0 <arrow::fs::(anonymous namespace)::RegionResolver::DefaultInstance()::instance>, __in_chrg=<optimized out>)
at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.1.0/bits/shared_ptr_base.h:1524
#28 0x00007ffff6a549f2 in std::shared_ptr<arrow::fs::(anonymous namespace)::RegionResolver>::~shared_ptr (
this=0x7ffff78298f0 <arrow::fs::(anonymous namespace)::RegionResolver::DefaultInstance()::instance>, __in_chrg=<optimized out>)
at /home/antoine/mambaforge/envs/pyarrow/x86_64-conda-linux-gnu/include/c++/12.1.0/bits/shared_ptr.h:175
#29 0x00007ffff1d738a7 in __run_exit_handlers (status=0, listp=0x7ffff1f19718 <__exit_funcs>, run_list_atexit=run_list_atexit@entry=true,
run_dtors=run_dtors@entry=true) at exit.c:108
#30 0x00007ffff1d73a60 in __GI_exit (status=<optimized out>) at exit.c:139
#31 0x00007ffff1d5108a in __libc_start_main (main=0x7ffff28e3030 <main>, argc=1, argv=0x7fffffffd7b8, init=<optimized out>, fini=<optimized out>,
rtld_fini=<optimized out>, stack_end=0x7fffffffd7a8) at ../csu/libc-start.c:342
#32 0x00005555555a26d9 in _start ()
Expected Behavior
S3Client destruction should not crash.
Current Behavior
See bug description above.
Reproduction Steps
I don't have any easy reproduction steps. The way it occurs is when I try to run the Apache Arrow S3 tests using the conda-forge package for aws-sdk-cpp version 1.10.9.
Possible Solution
No response
Additional Information/Context
No response
AWS CPP SDK version used
1.10.9
Compiler and Version used
Not sure (using the conda-forge package for aws-sdk-cpp)
Operating System and version
Ubuntu 20.04
@h-vetinari @xhochy FYI.
Have your reproduced this test locally with code other than the Apache Arrow S3 tests? Can you provide a minimal code sample and/or link to the failing tests?
Hi @pitrou , Thanks for contacting us. We've seen a similar report recently.
Could you please confirm that SDK API (including S3 client construction up to destruction) are executed within Init/Shutdown SDK scope? Please see the reference for details https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/basic-use.html
The way it occurs is when I try to run the Apache Arrow S3 tests using the conda-forge package for aws-sdk-cpp version 1.10.9.
Did you do a local pyarrow build with conda for that? Because the builds we're publishing so far cannot be coinstalled with aws-sdk-cpp 1.10
Did you do a local pyarrow build with conda for that?
Yes, on our development branch (git master). No code chance was required.
I'm experiencing the same issue after updating: Upload an object to an Amazon S3 bucket using an AWS SDK (https://docs.aws.amazon.com/AmazonS3/latest/userguide/example_s3_PutObject_section.html)
int main(int, char **)
{
Aws::SDKOptions options;
classB::initAwsApi(options);
while (true)
{
//...
if (threadApi.joinable())
threadApi.join();
threadApi = std::thread(request, &connection, &headers);
std::this_thread::sleep_for(std::chrono::seconds(5));
// if I close the stream, the error doesn't appear. But I would like to close the stream
stream_.release();
}
if (threadApi.joinable())
threadApi.join();
// when closing the SDK, the error appears
classB::shutdownAwsApi(options);
}
output: Fatal error condition occurred in /home/x/x/deps/aws-sdk-cpp/crt/aws-crt-cpp/crt/aws-c-common/source/allocator.c:209: allocator != ((void *)0) Exiting Application No call stack information available Aborted(core dumped)
Could you please confirm that SDK API (including S3 client construction up to destruction) are executed within Init/Shutdown SDK scope?
It is not easy for us to ensure Shutdown as we are exposing S3 functionality through our own library APIs.
Estou tendo o mesmo problema após a atualização: Carregar um objeto em um bucket do Amazon S3 usando um AWS SDK ( https://docs.aws.amazon.com/AmazonS3/latest/userguide/example_s3_PutObject_section.html )
int main(int, char **) { Aws::SDKOptions options; classB::initAwsApi(options); while (true) { //... if (threadApi.joinable()) threadApi.join(); threadApi = std::thread(request, &connection, &headers); std::this_thread::sleep_for(std::chrono::seconds(5)); // if I close the stream, the error doesn't appear. But I would like to close the stream stream_.release(); } if (threadApi.joinable()) threadApi.join(); // when closing the SDK, the error appears classB::shutdownAwsApi(options); }saída : Ocorreu uma condição de erro fatal em /home/x/x/deps/aws-sdk-cpp/crt/aws-crt-cpp/crt/aws-c-common/source/allocator.c:209: allocator ! = ((void *)0) Saindo do aplicativo Nenhuma informação de pilha de chamada disponível Abortado(core dump)
I changed the aws version to <1.9 and it worked!
Is there any update on this issue? I am experiencing the same problem (my application crashing) when freeing a S3Client object. Hopefully a fix for this is in the works because the two workarounds are to either leak memory or revert to an older version of this library. Both seem unacceptable to me. Thanks for looking into this matter as soon as possible.
Hi @pitrou , Thanks for contacting us. We've seen a similar report recently.
Could you please confirm that SDK API (including S3 client construction up to destruction) are executed within Init/Shutdown SDK scope? Please see the reference for details https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/basic-use.html
You shouldn't be seeing any crashes. Can you confirm that you are using the sdk correctly? If you don't include the middle {} then the shutdown can cause errors/crashes
#include <aws/core/Aws.h>
int main(int argc, char** argv)
{
Aws::SDKOptions options;
Aws::InitAPI(options);
{
// make your SDK calls here.
}
Aws::ShutdownAPI(options);
return 0;
}
Greetings! It looks like this issue hasn’t been active in longer than a week. We encourage you to check if this is still an issue in the latest release. Because it has been longer than a week since the last update on this, and in the absence of more information, we will be closing this issue soon. If you find that this is still a problem, please feel free to provide a comment or add an upvote to prevent automatic closure, or if the issue is already closed, please feel free to open a new one.