awslabs / awslabs/serverless-plugin-lambda-insights

Apple M1: thread 'main' panicked at 'attempt to divide by zero'

Open
#50 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
43
Forks
18
PR merge metrics
No merged PRs in 30d

Description

The problem seems to be when you are running on mac silicon using an x86 docker image.

Dockerfile:

```
FROM public.ecr.aws/lambda/python:3.11.2023.11.18.02
RUN curl -O https://lambda-insights-extension-arm64.s3-ap-northeast-1.amazonaws.com/amazon_linux/lambda-insights-extension-arm64.rpm && \
rpm -U lambda-insights-extension-arm64.rpm && \
rm -f lambda-insights-extension-arm64.rpm
RUN echo -e "def handler(event, context):\n return {'message': 'Hello World!'}" > index.py
CMD [ "index.handler" ]
```

Invocation - arm64 native docker container:

```
echo '{}' | http "http://localhost:9000/2015-03-31/functions/function/invocations"
HTTP/1.1 200 OK
Content-Length: 27
Content-Type: text/plain; charset=utf-8
Date: Fri, 08 Mar 2024 14:24:51 GMT

{
"message": "Hello World!"
}
```

Invocation - x86_64 on mac arm:

```
echo '{}' | http "http://localhost:9000/2015-03-31/functions/function/invocations"
HTTP/1.1 200 OK
Content-Length: 0
Date: Fri, 08 Mar 2024 14:26:40 GMT

```

Logs:

```
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
08 Mar 2024 14:26:35,087 [INFO] (rapid) exec '/var/runtime/bootstrap' (cwd=/var/task, handler=)
08 Mar 2024 14:26:37,980 [INFO] (rapid) extensionsDisabledByLayer(/opt/disable-extensions-jwigqn8j) -> stat /opt/disable-extensions-jwigqn8j: no such file or directory
08 Mar 2024 14:26:37,982 [INFO] (rapid) Configuring and starting Operator Domain
08 Mar 2024 14:26:37,983 [INFO] (rapid) Starting runtime domain
START RequestId: 66b137c2-a48d-42a9-8a03-d294f8d3ceb0 Version: $LATEST
08 Mar 2024 14:26:38,081 [INFO] (rapid) Starting runtime without AWS_SESSION_TOKEN , Expected?: false
08 Mar 2024 14:26:38,083 [INFO] (rapid) External agent cloudwatch_lambda_agent (1667ff46-e04b-443e-bc4b-43d0768a81f6) registered, subscribed to [INVOKE SHUTDOWN]
thread 'meter_probe' panicked at 'Unable to read /proc for agent process: InternalError(bug at /local/p4clients/pkgbuild-TjrGA/workspace/build/AWSLogsLambdaInsights/AWSLogsLambdaInsights-1.0.275.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/cargo-home/registry/src/-005bcb04bd8bbd75/procfs-0.11.1/src/process/stat.rs:310 (please report this procfs bug)
Internal Unwrap Error: Internal error: bug at /local/p4clients/pkgbuild-TjrGA/workspace/build/AWSLogsLambdaInsights/AWSLogsLambdaInsights-1.0.275.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/cargo-home/registry/src/-005bcb04bd8bbd75/procfs-0.11.1/src/lib.rs:257 (please report this procfs bug)
Internal Unwrap Error: NoneError)', src/inputs/memory.rs:59:39
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'attempt to divide by zero', src/inputs/memory.rs:44:32
08 Mar 2024 14:26:40,983 [WARNING] (rapid) First fatal error stored in appctx: Extension.Crash
08 Mar 2024 14:26:40,984 [WARNING] (rapid) Process extension-cloudwatch_lambda_agent-1 exited: exit status 101
08 Mar 2024 14:26:40,985 [WARNING] (rapid) AwaitAgentsReady() = exit status 101
END RequestId: b962017f-58cd-4ae3-9e15-1771b4025ab7
REPORT RequestId: b962017f-58cd-4ae3-9e15-1771b4025ab7 Init Duration: 1.96 ms Duration: 3002.61 ms Billed Duration: 3003 ms Memory Size: 3008 MB Max Memory Used: 3008 MB
: MADV_DONTNEED does not work (memset will be used instead)
: (This is the expected behaviour if you are running under QEMU)
timestamp = datetime.fromisoformat(event["timestamp"])ent_handler in decorate
[ERROR] [1709908019162] LAMBDA_RUNTIME Failed to post handler success response. Http response code: 400.
Traceback (most recent call last):
File "/var/runtime/bootstrap.py", line 63, in
main()
File "/var/runtime/bootstrap.py", line 60, in main
awslambdaricmain.main([os.environ["LAMBDA_TASK_ROOT"], os.environ["_HANDLER"]])
File "/var/lang/lib/python3.11/site-packages/awslambdaric/__main__.py", line 21, in main
bootstrap.run(app_root, handler, lambda_runtime_api_addr)
File "/var/lang/lib/python3.11/site-packages/awslambdaric/bootstrap.py", line 488, in run
handle_event_request(
File "/var/lang/lib/python3.11/site-packages/awslambdaric/bootstrap.py", line 214, in handle_event_request
lambda_runtime_client.post_invocation_error(
File "/var/lang/lib/python3.11/site-packages/awslambdaric/lambda_runtime_client.py", line 94, in post_invocation_error
runtime_client.post_error(invoke_id, error_response_data, xray_fault)
RuntimeError: Failed to post invocation error
08 Mar 2024 14:26:59,646 [WARNING] (rapid) Omitting fatal error Runtime.ExitError: Extension.Crash already stored
08 Mar 2024 14:26:59,646 [WARNING] (rapid) Process runtime-1 exited: exit status 1
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.