-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
s3-crt: Crash when calling PutObjectAsync without context #3171
Comments
Could you please paste your code snippet so that we can troubleshoot your specific case? |
You should be able to reproduce the issue with the following code snippet: #include <aws/core/Aws.h>
#include <aws/s3-crt/S3CrtClient.h>
#include <aws/s3-crt/model/PutObjectRequest.h>
#include <aws/core/utils/ratelimiter/DefaultRateLimiter.h>
#include <aws/core/auth/AWSCredentialsProvider.h>
#include <aws/core/utils/memory/stl/AWSStringStream.h>
#include <aws/core/utils/Outcome.h>
#include <iostream>
#include <fstream>
void UploadFileAsync(const Aws::String& bucket_name, const Aws::String& object_name, const Aws::String& file_path) {
Aws::S3Crt::S3CrtClient s3_client;
Aws::S3Crt::Model::PutObjectRequest request;
request.SetBucket(bucket_name);
request.SetKey(object_name);
auto file = Aws::MakeShared<Aws::FStream>("SampleAllocationTag", file_path.c_str(), std::ios_base::in | std::ios_base::binary);
if (!file->good()) {
std::cerr << "Failed to open file: " << file_path << std::endl;
return;
}
request.SetBody(file);
auto callback = [](const Aws::S3Crt::S3CrtClient* client,
const Aws::S3Crt::Model::PutObjectRequest& request,
const Aws::S3Crt::Model::PutObjectOutcome& outcome,
const std::shared_ptr<const Aws::Client::AsyncCallerContext>& context) {
if (outcome.IsSuccess()) {
std::cout << "File uploaded successfully!" << std::endl;
} else {
std::cerr << "Failed to upload file: " << outcome.GetError().GetMessage() << std::endl;
}
};
// SEGFAULT:
s3_client.PutObjectAsync(request, callback);
}
int main(int argc, char** argv) {
if (argc != 4) {
std::cerr << "Usage: " << argv[0] << " <bucket_name> <object_name> <file_path>" << std::endl;
return 1;
}
Aws::SDKOptions options;
Aws::InitAPI(options);
{
const Aws::String bucket_name(argv[1]);
const Aws::String object_name(argv[2]);
const Aws::String file_path(argv[3]);
UploadFileAsync(bucket_name, object_name, file_path);
std::this_thread::sleep_for(std::chrono::seconds(5));
}
Aws::ShutdownAPI(options);
return 0;
} A possible workaround is to pass a context to std::shared_ptr<Aws::Client::AsyncCallerContext> context =
Aws::MakeShared<Aws::Client::AsyncCallerContext>("PutObjectAllocationTag");
context->SetUUID("SOME_UUUID");
s3_client.PutObjectAsync(request, callback, context); |
I could replicate the issue. A bug fix is under way and will be available soon. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
We are encountering a segmentation fault when calling the PutObjectAsync method in the s3-crt client. The issue specifically occurs when the
Aws::Client::AsyncCallerContext
parameter is not provided.This issue did not occur with previous versions of the AWS SDK, suggesting a possible regression. Based on the timing, the problem may be linked to changes introduced in #3138.
Regression Issue
Expected Behavior
The program should execute without crashing, even when PutObjectAsync is called without an AsyncCallerContext.
Current Behavior
The program crashes with a segmentation fault.
Reproduction Steps
N/A
Possible Solution
No response
Additional Information/Context
No response
AWS CPP SDK version used
1.11.432
Compiler and Version used
(GCC) 13.3.0
Operating System and version
Linux / Yocto Scarthgap
The text was updated successfully, but these errors were encountered: