question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

Description:

I experience this error: thread 'main' panicked at 'attempt to divide by zero' when I try to access an endpoint on the function.

Steps to reproduce:

Run sam-beta-cdk local start-api -p <PORT> --skip-pull-image --warm-containers EAGER --debug

Observed result:

2021-08-20 09:00:27,794 | Found one Lambda function with name '<FUNCTION_NAME>'
2021-08-20 09:00:27,794 | Invoking Container created from <FUNCTION_NAME>
2021-08-20 09:00:27,794 | Environment variables overrides data is standard format
2021-08-20 09:00:27,814 | Reuse the created warm container for Lambda function '<FUNCTION_NAME>'
2021-08-20 09:00:27,821 | Lambda function '<FUNCTION_NAME>' is already running
2021-08-20 09:00:27,822 | Starting a timer for 10 seconds for function '<FUNCTION_NAME>'
START RequestId: <REQUEST_ID> Version: $LATEST
thread 'meter_probe' panicked at 'Unable to read /proc for agent process: InternalError(bug at /local/p4clients/pkgbuild-QP4Aq/workspace/build/AWSLogsLambdaInsights/AWSLogsLambdaInsights-1.0.115.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/cargo-home/registry/src/-c477fb05a7ac3d62/procfs-0.7.9/src/process/stat.rs:300 (please report this procfs bug)
Internal Unwrap Error: Internal error: bug at /local/p4clients/pkgbuild-QP4Aq/workspace/build/AWSLogsLambdaInsights/AWSLogsLambdaInsights-1.0.115.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/cargo-home/registry/src/-c477fb05a7ac3d62/procfs-0.7.9/src/lib.rs:285 (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

Expected result:

Return appropriate result from the endpoint

Additional environment details (Ex: Windows, Mac, Amazon Linux etc)

  1. OS: Big Sur v11.5.1
  2. sam --version: SAM CLI, version 1.22.0.dev202107140310
  3. AWS region: eu-central-1

Add --debug flag to command you are running

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kitsundecommented, Apr 10, 2022

@ssenchenko

This seem to happen across AWS lambda projects that include LambdaInsightsExtension. Also see this issue: https://github.com/aws/aws-sam-cli/issues/2469#issuecomment-985550710

We have the same issue on M1 macOS and are working around it by detecting the dummy account 123456789012 and not including the insights layer on local incoke.

Conditions:
  IsLocal: !Equals [123456789012, !Ref AWS::AccountId]

Then

Layers;
  - !If [!Ref IsLocal, "arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension:18", !Ref AWS::NoValue]

This happens when running:

sam local invoke MyFunction

Log:

Mounting /Foo/src as /var/task:ro,delegated inside runtime container
START RequestId: 58aa7e5d-12c9-4296-981a-08aaf62acb65 Version: $LATEST
thread 'meter_probe' panicked at 'Unable to read /proc for agent process: InternalError(bug at /local/p4clients/pkgbuild-Y79dR/workspace/build/AWSLogsLambdaInsights/AWSLogsLambdaInsights-1.0.135.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/cargo-home/registry/src/-83179af10ac8becc/procfs-0.11.1/src/process/stat.rs:310 (please report this procfs bug)
Internal Unwrap Error: Internal error: bug at /local/p4clients/pkgbuild-Y79dR/workspace/build/AWSLogsLambdaInsights/AWSLogsLambdaInsights-1.0.135.0/AL2_x86_64/DEV.STD.PTHREAD/build/private/cargo-home/registry/src/-83179af10ac8becc/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
0reactions
mo2menelzeinycommented, Oct 5, 2022

I think this is the expected behaviour, if you’re on Apple M1 you should use the arm64 as it pulls the appropriate images to your docker engine, so the LayerVersionArn would be: !Sub arn:aws:lambda:${AWS::Region}:580247275435:layer:LambdaInsightsExtension-Arm64:2

But then you would have to run your Lambda in arm64 as well

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apple M1: thread 'main' panicked at 'attempt to divide by zero'
CLI tool to build, test, debug, and deploy Serverless applications using AWS SAM - Apple M1: thread 'main' panicked at 'attempt to divide...
Read more >
Macbook Air M1 - kernel panic - Apple Community
Macbook Air M1 - kernel panic. With a slightly higher CPU load (during the game), there are repeated restarts, pink stripes appear on...
Read more >
How should I handle f64 division by zero panic elegantly? - help
The Vue "frontend" handles the state of the stack for calculation. Any calculator operations are passed to Rust through Wasm and handled there....
Read more >
C++ Core Guidelines - GitHub Pages
0 : Don't panic! Take the time to understand the implications of a guideline rule on your program. These guidelines are designed according...
Read more >
Reading a Panic Log in Catalina - The Eclectic Light Company
followed by series of backtrace details is of no use to regular users. Kernel Extensions in backtrace: com.apple.iokit.IOAcceleratorFamily2( ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found