AWS c++ Lambda -分段错误



我已经成功地在WSL上安装了一个AWS CLI。此外,我确实遵循了这些指示:https://aws.amazon.com/blogs/compute/introducing-the-c-lambda-runtime/

现在,第一个例子工作了,当我运行一个测试用例时,一切都正常运行,测试成功。但是,当我用带有测试的编码器运行上面链接中的示例时,执行失败了。

这是错误日志:

s2n_init() failed: 402653268 (Failed to load or unload an openssl provider)
Fatal error condition occurred in /home/username/aws-sdk-cpp/crt/aws-crt-cpp/crt/aws-c-io/source/s2n/s2n_tls_channel_handler.c:197: 0 && "s2n_init() failed"
Exiting Application
No call stack information available
START RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Version: $LATEST
2022-11-21T09:02:07.642Z xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Task timed out after 1.02 seconds
END RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
REPORT RequestId: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx  Duration: 1015.50 ms    Billed Duration: 1000 ms    Memory Size: 128 MB Max Memory Used: 16 MB  

这里有两个提示:

  1. 加载或卸载openssl提供程序失败
  2. 证书显示错误发生的位置。这个位置是我的本地机器,我觉得很奇怪,因为(二进制)代码上传到AWS并在那里运行,而不是在我的本地机器上?

我是否错过了某个安装步骤或我的配置不正确?我能做些什么来为自己提供更多的信息和/或解决问题?

此解决方案有效- https://www.mail-archive.com/openssl-users@openssl.org/msg91357.html。(在aws-sdk-cpp中禁用S2N_LIBCRYPTO_SUPPORTS_EVP_RC4)

在@barath的帮助下,我成功了。我想形成一个完整的答案,因为这里有两个问题要解决:

1)"beyond hello"中有一个bug示例的main.cpp代码

S3::S3Client client(credentialsProvider, config);

必须:

S3::S3Client client(config);

2)要消除s2n_init()错误,需要按照barath解释的那样做:

nano ~/aws-sdk-cpp/crt/aws-crt-cpp/crt/s2n/CMakeLists.txt -l

将第414行注释为从第413行到第415行如下所示

if (LIBCRYPTO_SUPPORTS_EVP_RC4)
#target_compile_options(${PROJECT_NAME} PUBLIC -DS2N_LIBCRYPTO_SUPPORTS_EVP_RC4)
endif()

保存文件

nano ~/aws-sdk-cpp/crt/aws-crt-cpp/crt/s2n/s2n.mk -l

在~223行添加注释,这样从~222行开始,代码看起来像:

ifeq ($(TRY_EVP_RC4), 0)
#DEFAULT_CFLAGS += -DS2N_LIBCRYPTO_SUPPORTS_EVP_RC4
endif

现在可以在https://aws.amazon.com/blogs/compute/introducing-the-c-lambda-runtime/上继续使用

$ cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=~/out
$ make
$ make aws-lambda-package-encoder

当lambda函数在不同于lambda运行时映像的docker映像中构建时,会发生此错误。

例如:

  • 构建代码的Docker映像- AmazonLinux(无标签,最新版本)
  • Lambda Runtime OS - AmazonLinux:2

最新更新