aws lambda c++ runtime seg fault (but works locally)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 25/100
Research direction
Start at the my_handler entry point and reproduce the AWS Lambda failure around rapidcsv::Document and torch::jit::load. Compare the AWS runtime execution with the Debian/CMake run, checking the S3 GetObject results and retrieved streams before each failing line. Done means identifying the runtime-specific cause of the segmentation fault and documenting a verified fix.
Written by the indexing model from the issue text.
Description
I am trying to get a simple example running on aws c++ runtime, but it keeps seg faulting when I invoke the lambda function. To start with, the example shown in: https://aws.amazon.com/blogs/compute/introducing-the-c-lambda-runtime/ works fine. So, now, I fetch something from a bucket like so:
#include <aws/core/Aws.h>
#include <aws/core/client/ClientConfiguration.h>
#include <aws/core/auth/AWSCredentialsProvider.h>
#include <aws/s3/S3Client.h>
#include <aws/s3/model/GetObjectRequest.h>
#include <awsdoc/s3/s3_examples.h>
#include <vector>
#include <rapidcsv.h>
#include <torch/torch.h>
#include <torch/script.h> // One-stop header.
#include <iostream>
#include <math.h>
#include <memory>
#include <aws/lambda-runtime/runtime.h>
using namespace torch::indexing;
using namespace Aws::Utils;
using namespace aws::lambda_runtime;
char const TAG[] = "LAMBDA_ALLOC";
static invocation_response my_handler(invocation_request const &req)
{
if (req.payload.length() > 42)
{
return invocation_response::failure("error message here" /*error_message*/,
"error type here" /*error_type*/);
}
Aws::SDKOptions options;
Aws::InitAPI(options);
const Aws::String bucket_name("buckname");
const Aws::String object_name("fname");
Aws::S3::S3Client s3_client;
Aws::S3::Model::GetObjectRequest object_request;
object_request.SetBucket(bucket_name);
object_request.SetKey(object_name);
Aws::S3::Model::GetObjectOutcome get_object_outcome =
s3_client.GetObject(object_request);
auto &retrieved_file = get_object_outcome.GetResultWithOwnership().GetBody();
rapidcsv::Document doc(retrieved_file, rapidcsv::LabelParams(-1, -1)); /// this is where the problem is.
const Aws::String objectKey2("traced_pointnet_model.tar");
Aws::S3::S3Client s3_client2;
Aws::S3::Model::GetObjectRequest object_request2;
object_request2.SetBucket(bucket_name);
object_request2.SetKey(objectKey2);
Aws::S3::Model::GetObjectOutcome get_object_outcome2 =
s3_client2.GetObject(object_request2);
auto &retrieved_file2 = get_object_outcome2.GetResultWithOwnership().GetBody();
torch::jit::script::Module module;
module = torch::jit::load(retrieved_file2); /// this is also where the problem is.
std::cout << "Model Load ok\n";
Aws::ShutdownAPI(options);
return invocation_response::success(tensor_string /*payload*/,
"application/json" /*MIME type*/);
}
int main()
{
run_handler(my_handler);
return 0;
}
the thing is, it compiles and works as expected when I run it locally (debian, cmake), but when I compile it for aws runtime, I get the seg fault.
I have narrowed down the problem to two lines:
rapidcsv::Document doc(retrieved_file, rapidcsv::LabelParams(-1, -1)); /// this is where the problem is.
and also,
module = torch::jit::load(retrieved_file2); /// this is also where the problem is.
I use the rapidcsv header only lib from here: https://github.com/d99kris/rapidcsv and as I said, it works fine locally.
I suspect somehow the runtime is not able to find rapidcsv (but that still fails to explain why it seg faults on module = torch::jit::load(retrieved_file2); :(
Any pointers would be great!
- Dominant language
- C++
- Stars
- 465
- Forks
- 98
- Avg merge
- 1h 16m
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from awslabs/aws-lambda-cpp
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
awslabs/aws-lambda-cpp#205 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
awslabs/aws-lambda-cpp#196 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
awslabs/aws-lambda-cpp#195 · 11 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
awslabs/aws-lambda-cpp#194 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
awslabs/aws-lambda-cpp#188 ·
All issues in awslabs/aws-lambda-cpp
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
objectionary/eo-graphs#74 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
enhancement
Difficulty 1/5 Under an hour Newbie friendliness 88/100
QuantStack/git2cpp#187 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100