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.

Lambda ARM (Apple M1): AWS SAM Golang lambda debugging does not work

See original GitHub issue

Description:

After creating a plain vanilla AWS SAM application with sam init for golang, and then using the AWS Toolkit provided code lens in VS Code, to create an AWS SAM template file based debug configuration, I get the following error when trying to debug the lambda code.

Running the code without debugging works.

Note: I had raised this issue in aws/aws-toolkit-vscode as aws/aws-toolkit-vscode#2020. There was a suggestion in that thread that I should raise an issue here.

Steps to reproduce:

  1. Create a new AWS SAM application using Go with sam init.
  2. Select the Hello world template.
  3. In the main.go file, create a debug configuration from the code lens provided by the AWS Toolkit and associated with the handler.
  4. Set a breakpoint and start debugging.

Observed result:

2021-09-11 10:55:02 [INFO]: The Delve repo was not found in your GOPATH. Downloading in a temporary directory...
2021-09-11 10:55:03 [INFO]: Preparing to debug locally: Lambda "hello-world"
2021-09-11 10:55:03 [INFO]: Building SAM application...
2021-09-11 10:55:03 [INFO]: Running command: (not started) [/opt/homebrew/bin/sam build --build-dir /tmp/aws-toolkit-vscode/vsctkeYZ6BB/output --template /Users/user1/dev/godev/aws/lambdas/hello-world/hello-world/app___vsctk___template.yaml --base-dir /Users/user1/dev/godev/aws/lambdas/hello-world/hello-world]
2021-09-11 10:55:03 [INFO]: Building codeuri: /Users/user1/dev/godev/aws/lambdas/hello-world/hello-world runtime: go1.x metadata: {} functions: ['helloworld']

2021-09-11 10:55:03 [INFO]: Running GoModulesBuilder:Build

2021-09-11 10:55:03 [INFO]: 
Build Succeeded

2021-09-11 10:55:03 [INFO]: 
Built Artifacts  : ../../../../../../../private/tmp/aws-toolkit-vscode/vsctkeYZ6BB/output
Built Template   : ../../../../../../../private/tmp/aws-toolkit-vscode/vsctkeYZ6BB/output/template.yaml

Commands you can use next
=========================
[*] Invoke Function: sam local invoke -t ../../../../../../../private/tmp/aws-toolkit-vscode/vsctkeYZ6BB/output/template.yaml
[*] Deploy: sam deploy --guided --template-file ../../../../../../../private/tmp/aws-toolkit-vscode/vsctkeYZ6BB/output/template.yaml
    

2021-09-11 10:55:04 [INFO]: Build complete.
2021-09-11 10:55:04 [INFO]: Starting SAM application locally
2021-09-11 10:55:05 [INFO]: AWS.running.command
Invoking hello-world (go1.x)
Requested to skip pulling images ...

Mounting /tmp/aws-toolkit-vscode/vsctkeYZ6BB/output/helloworld as /var/task:ro,delegated inside runtime container
START RequestId: 7c546e9e-8558-4fde-8dd6-fc6946034850 Version: $LATEST
API server listening at: [::]:5858
2021-09-11T00:55:07Z info layer=debugger launching process with args: [/var/task/hello-world]
2021-09-11 10:55:07 [INFO]: Waiting for SAM application to start...
could not launch process: fork/exec /var/task/hello-world: function not implemented
2021/09/11 00:55:07 exit status 1
time="2021-09-11T00:55:07.765" level=error msg="Init failed" InvokeID= error="Runtime exited with error: exit status 1"
time="2021-09-11T00:55:07.773" level=error msg="INIT DONE failed: Runtime.ExitError"
2021-09-11 10:55:08 [INFO]: Attaching debugger to SAM application...

Command stopped: "sam local invoke"

From the output listed above, it seems to me that when using the debugger, it thinks that the function is not implemented. 2021-09-11 10:55:07 [INFO]: Waiting for SAM application to start… could not launch process: fork/exec /var/task/hello-world: function not implemented

Other considerations

  • Go debugging works for vanilla go apps (non lambdas) on M1 based Apple Macs.
  • Go lambdas run successfully with sam local invoke on M1 based Apple Macs.
  • Go lambdas can be successfully debugged on x86 based Apple Macs.

Expected result:

  • Lambda debugging working with breakpoints being hit.

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

  1. OS: macOS Big Sur 11.6 (M1) / Darwin arm64 20.6.0
  2. sam --version: 1.31.0
  3. AWS region: any (currently working in ap-south-1)
  4. VS Code version: 1.16
  5. AWS Toolkit extension version: 1.29.0
  6. Go version: 1.17.1
  7. dlv and dlv-dap version: 1.7.1 Build: $Id: 3bde2354aafb5a4043fd59838842c4cd4a8b6f0b $
  8. Docker version: 20.10.8, build 3967b7d

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:12
  • Comments:21 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
jeremyforancommented, Jan 27, 2022

I am having the same issue.

Model Name:	MacBook Pro
Model Identifier: MacBookPro17,1
Chip: Apple M1
Total Number of Cores:	8 (4 performance and 4 efficiency)
Memory:	16 GB
System Firmware Version: 7429.61.2
OS Loader Version:	7429.61.2
2reactions
V4G4Xcommented, Aug 5, 2022

Just for reference, I wanted to drop the info that the above issue is experienced even when using sam-cli locally in debug mode, as opposed to using VS Code.

❯ sam local invoke -d 5858 --debugger-path $GOPATH/bin/linux_amd64/
Invoking hello-world (go1.x)
Skip pulling image and use local one: public.ecr.aws/sam/emulation-go1.x:rapid-1.53.0-x86_64.

Mounting /Users/varungawande/playground/goLambdaDebug/sunflowers/.aws-sam/build/HelloWorldFunction as /var/task:ro,delegated inside runtime container
START RequestId: 21a7a6c7-c9ee-4bee-8c77-5be8cdc3a9c6 Version: $LATEST
API server listening at: [::]:5858
2022-08-05T04:16:43Z warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)
2022-08-05T04:16:43Z info layer=debugger launching process with args: [/var/task/hello-world]
could not launch process: fork/exec /var/task/hello-world: function not implemented
2022/08/05 04:16:43 exit status 1
05 Aug 2022 04:16:43,434 [ERROR] (rapid) Init failed error=Runtime exited with error: exit status 1 InvokeID=
API server listening at: [::]:5858
2022-08-05T04:16:43Z warning layer=rpc Listening for remote connections (connections are not authenticated nor encrypted)
2022-08-05T04:16:43Z info layer=debugger launching process with args: [/var/task/hello-world]
could not launch process: fork/exec /var/task/hello-world: function not implemented
2022/08/05 04:16:43 exit status 1
END RequestId: 04bbf54c-1711-4a3c-bd9f-668866f340ff
REPORT RequestId: 04bbf54c-1711-4a3c-bd9f-668866f340ff	Init Duration: 1.51 ms	Duration: 1294.62 msBilled Duration: 1295 ms	Memory Size: 128 MB	Max Memory Used: 128 MB
Read more comments on GitHub >

github_iconTop Results From Across the Web

M1 Mac (Apple Silicon): AWS SAM Golang lambda debugging ...
How to get my AWS SAM initiated local debugging of lambda's written in Go working? Summary of the problem. After creating a plain...
Read more >
Golang AWS SAM lambda Function debugging is not working ...
When trying to debug simple SAM, I'm receiving the following error: could not launch process: fork/exec /var/task/hello: function not ...
Read more >
Migrating AWS Lambda functions to Arm-based AWS ...
This blog post highlights some considerations when moving from x86 to arm64 as the migration process is code and workload dependent. Functions ...
Read more >
Installing the AWS SAM CLI - AWS Serverless Application Model
This section describes how to install the AWS SAM CLI on macOS, Windows, and Linux.
Read more >
Step-through debugging Lambda functions locally
You can use AWS SAM with a variety of AWS toolkits and debuggers to test and ... you to find and troubleshoot issues...
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