Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

aws lambda c++ runtime seg fault (but works locally)

未关闭
#108 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
25/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
aws, cpp
领域
backend, cloud

调研方向

从入口点 my_handler 开始,重现与 rapidcsv::Document 和 torch::jit::load 相关的 AWS Lambda 故障。将 AWS runtime 中的执行与 Debian/CMake 运行进行比较,在每一行失败之前检查 S3 GetObject 的结果和获取到的流。完成标准是确定导致 segmentation fault 的 runtime 特定原因,并记录经过验证的修复方法。

由索引模型根据 Issue 内容生成。

描述

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!

主要语言
C++
星标
465
派生
98
平均合并
1 小时 16 分钟
30 天内合并 PR
2

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

awslabs/aws-lambda-cpp 的其他 Issue

查看 awslabs/aws-lambda-cpp 的全部 Issue

相似的 Issue

更多 C++ Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。