Skip to content

Bug: Cannot attach to debugger for Apple ARM-Based Chip in VS Code #7828

@hungnvo

Description

@hungnvo

Description:

When attempting to attach a debugger to a locally running AWS Lambda function using the SAM CLI on an Apple ARM-based chip (e.g., M1/M2), the debugger keep hanging and never attached. My guess is potentially due to compatibility issues between the debugger, SAM CLI, and Docker on the ARM architecture.

Steps to reproduce:

  1. Create new directory
mkdir -p ~/.vsdbg
  1. Use Docker to download and install vsdbg for the AWS Lambda runtime container with .NET 6 and copy it to local machine
docker run --rm --mount type=bind,src=~/.vsdbg,dst=/vsdbg --entrypoint bash lambci/lambda:dotnet6.0 -c "curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /vsdbg"
  1. Build SAM
sam build
  1. SAM local start api
sam local start-api --port 1111 --skip-pull-image --debug-port 5858 --debugger-path ~/.vsdbg --warm-containers EAGER
  1. Start launch.json
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": ".NET Core Docker Attach",
      "type": "coreclr",
      "request": "attach",
      "processId": "1",

      "pipeTransport": {
        "pipeProgram": "sh",
        "pipeArgs": [ 
          "-c",
          "docker exec -i $(docker ps -q -f publish=5858) ${debuggerCommand}"
        ],
        "debuggerPath": "/tmp/lambci_debug_files/vsdbg",
        "pipeCwd": "${workspaceFolder}",
      },
      "sourceFileMap": {
        "/var/task": "${workspaceFolder}"
      }
    }
  ]
}

I attempted to try both run the launch.json file before and after hitting the endpoint to see if it makes any different.

Observed result:

No breakpoint were hit. the debugger keep hanging and never actually attached.

Expected result:

It will actually hit the breakpoints.

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

  1. OS: MacOS Apple M3
  2. sam --version: 1.132
  3. Lambda Runtime: dotnet6
{
  "version": "1.132.0",
  "system": {
    "python": "3.13.1",
    "os": "macOS-15.2-arm64-arm-64bit-Mach-O"
  },
  "additional_dependencies": {
    "docker_engine": "27.3.1",
    "aws_cdk": "Not available",
    "terraform": "Not available"
  },
  "available_beta_feature_env_vars": [
    "SAM_CLI_BETA_FEATURES",
    "SAM_CLI_BETA_BUILD_PERFORMANCE",
    "SAM_CLI_BETA_TERRAFORM_SUPPORT",
    "SAM_CLI_BETA_RUST_CARGO_LAMBDA"
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions