Description
Describe the bug
I want to turn off S3CrtClient's default behaviour of doing multi-range GETs and multi-part PUTs. So I set
Aws::S3Crt::ClientConfiguration.partSize set to 5GB. So that only for objects greater than 5GB, will a multi-part PUT will happen (5GB is chosen because that is the size limit of a single PUT call). Otherwise, I want only a single PUT/GET to happen for objects lesser than 5GB.
However, my application is crashing. As per the stack trace, it seems the client is automatically doing a ranged GET of 5GB in size and trying to allocate a buffer of that size, which results in an assertion failing as the buffer pool limit is only 2GB, resulting in SIGABRT.
Here's the stack trace:
Fatal error condition occurred in /Users/rohan/cb/aws-sdk-cpp/crt/aws-crt-cpp/crt/aws-c-s3/source/s3_buffer_pool.c:258: size <= buffer_pool->mem_limit
Exiting Application
################################################################################
Stack trace:
################################################################################
1 libaws-c-common.1.0.0.dylib 0x000000010189dcec aws_backtrace_print + 200
2 libaws-c-common.1.0.0.dylib 0x0000000101860318 aws_fatal_assert + 104
3 libaws-c-s3.1.0.0.dylib 0x00000001011de210 aws_s3_buffer_pool_reserve + 204
4 libaws-c-s3.1.0.0.dylib 0x00000001011d59f8 s_s3_auto_ranged_get_update + 1360
5 libaws-c-s3.1.0.0.dylib 0x00000001011f4ba4 aws_s3_meta_request_update + 220
6 libaws-c-s3.1.0.0.dylib 0x00000001011e660c aws_s3_client_update_meta_requests_threaded + 348
7 libaws-c-s3.1.0.0.dylib 0x00000001011e9b08 s_s3_client_process_work_default + 1312
8 libaws-c-s3.1.0.0.dylib 0x00000001011ea5d0 s_s3_client_process_work_task + 324
9 libaws-c-common.1.0.0.dylib 0x00000001018a6760 aws_task_run + 308
10 libaws-c-common.1.0.0.dylib 0x00000001018a6e7c s_run_all + 512
11 libaws-c-common.1.0.0.dylib 0x00000001018a7ac8 aws_task_scheduler_run_all + 88
12 libaws-c-io.1.0.0.dylib 0x00000001017dd434 aws_event_loop_thread + 1676
13 libaws-c-common.1.0.0.dylib 0x000000010189ef6c thread_fn + 532
14 libsystem_pthread.dylib 0x0000000197c66f94 _pthread_start + 136
15 libsystem_pthread.dylib 0x0000000197c61d34 thread_start + 8
Using lldb to print the meta_request->part_size:
(lldb) f 5
frame #5: 0x0000000100da99f8 libaws-c-s3.0unstable.dylib`s_s3_auto_ranged_get_update(meta_request=0x0000000142b671f0, flags=2, out_request=0x000000016ff05ae8) at s3_auto_ranged_get.c:301:38
298 * even if expect to receive less data. Pool will
299 * reserve the whole part size for it anyways, so no
300 * reason getting a smaller chunk. */
-> 301 ticket = aws_s3_buffer_pool_reserve(
302 meta_request->client->buffer_pool, (size_t)meta_request->part_size);
303
304 if (ticket == NULL) {
(lldb) p meta_request->part_size
(const size_t) 5368709120
The buffer pool limit being:
(lldb) f 4
frame #4: 0x0000000100db2210 libaws-c-s3.0unstable.dylib`aws_s3_buffer_pool_reserve(buffer_pool=0x00006000009e4a90, size=5368709120) at s3_buffer_pool.c:258:5
255 }
256
257 AWS_FATAL_ASSERT(size != 0);
-> 258 AWS_FATAL_ASSERT(size <= buffer_pool->mem_limit);
259
260 struct aws_s3_buffer_pool_ticket *ticket = NULL;
261 aws_mutex_lock(&buffer_pool->mutex);
(lldb) p buffer_pool->mem_limit
(size_t) 2013265920
Expected Behavior
No crash should happen.
Current Behavior
Application crashes.
Reproduction Steps
Aws::S3Crt::ClientConfiguration config;
config.partSize = 5 * 1024 * 1024 * 1024ULL;
client = std::make_unique<Aws::S3Crt::S3CrtClient>(config);
Aws::S3Crt::Model::GetObjectRequest request;
request.SetBucket(bucketName);
request.SetKey(key);
auto outcome = client->GetObject(request); // CRASH
Possible Solution
No response
Additional Information/Context
I also tried setting config.downloadMemoryUsageWindow = 100 * 1024 * 1024;
but has no effect and I still see the crash.
What I am looking for is to not do ranged GETs for objects smaller than 5GB. Similarly, not do multi-part PUTs for objects smaller than 5GB.
AWS CPP SDK version used
1.11.411
Compiler and Version used
Apple clang version 15.0.0 (clang-1500.3.9.4)
Operating System and version
MacOS 14.4.1