Repository: nektos/act (language: go)

Issue:
Issue: signal SIGSEGV: segmentation violation
## System information

  - Operating System: `Windows + WSL2`
  - Architecture: `x64 (64-bit)`
  - Apple M1: `no`
  - Docker version: `20.10.14`
  - Docker image used in act: `nektos/act-environments-ubuntu:20.04`
  - act version: `0.2.26`

## Expected behavior

`act -n -P self-hosted=nektos/act-environments-ubuntu:20.04` should dryrun all workflows/jobs or report an error.


## Actual behaviour

act begins to run and appears to process some jobs, then segfault crashes

## Workflow and/or repository

Working on a repo that's publicly accessible.

<details>
  <summary>workflow</summary>

```none
Link to sample repo coming...
```

</details>

## Steps to reproduce

1. Clone example repo (https://github.com/rainabba/tbd-act-segfault-repo)
2. Enter cloned repo directory
3. Run `act -v -n -P self-hosted=nektos/act-environments-ubuntu:20.04`


## `act` output

See log

<details>
  <summary>Log</summary>

```none
$ act -n -P self-hosted=nektos/act-environments-ubuntu:20.04
*DRYRUN* [Trigger Automerge Dev Integration Branch/dispatch      ] 🚀  Start image=nektos/act-environments-ubuntu:20.04
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions] 🚀  Start image=nektos/act-environments-ubuntu:20.04
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions]   🐳  docker pull image=nektos/act-environments-ubuntu:20.04 platform= username= forcePull=false
*DRYRUN* [Trigger Automerge Dev Integration Branch/dispatch      ]   🐳  docker pull image=nektos/act-environments-ubuntu:20.04 platform= username= forcePull=false
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions]   🐳  docker create image=nektos/act-environments-ubuntu:20.04 platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions]   🐳  docker run image=nektos/act-environments-ubuntu:20.04 platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
*DRYRUN* [Trigger Automerge Dev Integration Branch/dispatch      ]   🐳  docker create image=nektos/act-environments-ubuntu:20.04 platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
*DRYRUN* [Trigger Automerge Dev Integration Branch/dispatch      ]   🐳  docker run image=nektos/act-environments-ubuntu:20.04 platform= entrypoint=["/usr/bin/tail" "-f" "/dev/null"] cmd=[]
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions] ⭐  Run generate github DASH access token
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions]   ✅  Success - generate github DASH access token
*DRYRUN* [Trigger Automerge Dev Integration Branch/dispatch      ] ⭐  Run generate github DASH access token
*DRYRUN* [Trigger Automerge Dev Integration Branch/dispatch      ]   ✅  Success - generate github DASH access token
*DRYRUN* [Trigger Automerge Dev Integration Branch/dispatch      ] ⭐  Run extract and set auth token from DASH JSON response
*DRYRUN* [Trigger Automerge Dev Integration Branch/dispatch      ]   ✅  Success - extract and set auth token from DASH JSON response
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions] ⭐  Run extract and set auth token from DASH JSON response
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions]   ✅  Success - extract and set auth token from DASH JSON response
*DRYRUN* [Trigger Automerge Dev Integration Branch/dispatch      ] ⭐  Run send dispatch event
*DRYRUN* [Trigger Automerge Dev Integration Branch/dispatch      ]   ✅  Success - send dispatch event
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions] ⭐  Run checkout current repo's main branch
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions]   ☁  git clone 'https://github.com/actions/checkout' # ref=v3
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions]   ✅  Success - checkout current repo's main branch
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions] ⭐  Run checkout automation actions
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions]   ☁  git clone 'https://github.com/actions/checkout' # ref=v3
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions]   ✅  Success - checkout automation actions
*DRYRUN* [Backmerge via Automation Action/backmerge-using-actions] ⭐  Run automerge PR job for main branch into develop
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x71 pc=0xa2402e]

goroutine 59 [running]:
github.com/docker/docker/client.(*Client).getAPIPath(0x7fd98c9ca490, {0xd3f9c8, 0xc00009e510}, {0xc0008093b0, 0x14}, 0x14)
        /home/runner/go/pkg/mod/github.com/docker/docker@v20.10.13+incompatible/client/client.go:183 +0x4e
github.com/docker/docker/client.(*Client).sendRequest(0xc28efa, {0xd3f9c8, 0xc00009e510}, {0xc288d9, 0x3}, {0xc0008093b0, 0x0}, 0x3, {0x0, 0x0}, ...)
        /home/runner/go/pkg/mod/github.com/docker/docker@v20.10.13+incompatible/client/request.go:109 +0x85
github.com/docker/docker/client.(*Client).get(...)
        /home/runner/go/pkg/mod/github.com/docker/docker@v20.10.13+incompatible/client/request.go:37
github.com/docker/docker/client.(*Client).CopyFromContainer(0x75, {0xd3f9c8, 0xc00009e510}, {0x0, 0x0}, {0xc00056a180, 0xc0008097a0})
        /home/runner/go/pkg/mod/github.com/docker/docker@v20.10.13+incompatible/client/container_copy.go:68 +0x207
github.com/nektos/act/pkg/container.(*containerReference).GetContainerArchive(0xc000809790, {0xd3f9c8, 0xc00009e510}, {0xc00056a180, 0x44e837})
        /home/runner/work/act/act/pkg/container/docker_run.go:164 +0x59
github.com/nektos/act/pkg/runner.(*StepContext).Executor.func1.1({0xc2c636, 0x0})
        /home/runner/work/act/act/pkg/runner/step_context.go:70 +0xc6
github.com/nektos/act/pkg/runner.(*StepContext).readAction(0xd3f9c8, 0xc000490700, {0xc0003f17a0, 0x6a}, {0x0, 0x0}, 0xc00017b470, 0xc70248)
        /home/runner/work/act/act/pkg/runner/action.go:25 +0x9c
github.com/nektos/act/pkg/runner.(*StepContext).setupAction.func1({0xd3f9c8, 0xc00009e510})
        /home/runner/work/act/act/pkg/runner/step_context.go:387 +0x9f
github.com/nektos/act/pkg/common.Executor.Then.func1({0xd3f9c8, 0xc00009e510})
        /home/runner/work/act/act/pkg/common/executor.go:131 +0x34
github.com/nektos/act/pkg/runner.(*RunContext).newStepExecutor.func1({0xd3f9c8, 0xc00009e510})
        /home/runner/work/act/act/pkg/runner/run_context.go:360 +0x35a
github.com/nektos/act/pkg/runner.newJobExecutor.func2.1(0xd3f9c8, {0xd3f9c8, 0xc00009e510})
        /home/runner/work/act/act/pkg/runner/job_executor.go:42 +0x36
github.com/nektos/act/pkg/runner.newJobExecutor.func2({0xd3f9c8, 0xc00017a2d0})
        /home/runner/work/act/act/pkg/runner/job_executor.go:51 +0x8d
github.com/nektos/act/pkg/common.Executor.Then.func1({0xd3f9c8, 0xc00017a2d0})
        /home/runner/work/act/act/pkg/common/executor.go:143 +0xe4
github.com/nektos/act/pkg/common.Executor.Then.func1({0xd3f9c8, 0xc00017a2d0})
        /home/runner/work/act/act/pkg/common/executor.go:131 +0x34
github.com/nektos/act/pkg/common.Executor.Then.func1({0xd3f9c8, 0xc00017a2d0})
        /home/runner/work/act/act/pkg/common/executor.go:131 +0x34
github.com/nektos/act/pkg/common.Executor.Then.func1({0xd3f9c8, 0xc00017a2d0})
        /home/runner/work/act/act/pkg/common/executor.go:131 +0x34
github.com/nektos/act/pkg/common.Executor.Finally.func1({0xd3f9c8, 0xc00017a2d0})
        /home/runner/work/act/act/pkg/common/executor.go:177 +0x34
github.com/nektos/act/pkg/common.Executor.Finally.func1({0xd3f9c8, 0xc00017a2d0})
        /home/runner/work/act/act/pkg/common/executor.go:177 +0x34
github.com/nektos/act/pkg/runner.(*RunContext).Executor.func1({0xd3f9c8, 0xc00017a2d0})
        /home/runner/work/act/act/pkg/runner/run_context.go:290 +0x67
github.com/nektos/act/pkg/common.Executor.Finally.func1({0xd3f9c8, 0xc00017a2d0})
        /home/runner/work/act/act/pkg/common/executor.go:177 +0x34
github.com/nektos/act/pkg/runner.(*runnerImpl).NewPlanExecutor.func1.1({0xd3f9c8, 0xc000395f20})
        /home/runner/work/act/act/pkg/runner/runner.go:171 +0x305
github.com/nektos/act/pkg/common.NewParallelExecutor.func1.1(0x0, 0x0)
        /home/runner/work/act/act/pkg/common/executor.go:102 +0x5c
created by github.com/nektos/act/pkg/common.NewParallelExecutor.func1
        /home/runner/work/act/act/pkg/common/executor.go:100 +0x8e
```

## Workflow and/or repository

Repo is private and complex so reproducing in full detail will be a challenge so I'm giving you the thinnest version that runs (no syntax errors and leads to crash).
```none
name: Build and Validate

on: 
  workflow_dispatch:
    inputs:
      build-branch:
        description: Build branch
        type: string
        default: master

env:
  RUN_UNIT_TESTS: 'true'
  RUN_ESLINT: 'false'
  RUN_TEST_COVERAGE: 'true'
  BUILD_BRANCH: 'master'

jobs:
  build-projects:
    runs-on: [self-hosted,npr-common-1gb]

    name: Validate ${{ matrix.working-directory }} - ${{ matrix.build-mode }} - ${{ matrix.node-version }}

    outputs: 
      auth_token: ${{ steps.extract-token.outputs.auth_token }}

    strategy:
      fail-fast: false
      matrix:
        working-directory: [
          src/sub-project-1,
          src/sub-project-2
        ]
        node-version: [14.x]
        build-mode: [ ecs,sls ]

    defaults:
      run:
        working-directory: ${{ matrix.working-directory }}

    steps:
    - name: Determine build branch
      if: github.event.inputs.build-branch != ''
      run: echo "BUILD_BRANCH=${{ github.event.inputs.build-branch }}" >> $GITHUB_ENV

    - uses: actions/checkout@v2
      name: Check out repository at ${{ env.BUILD_BRANCH }}
      with:
        persist-credentials: false
        ref: ${{ env.BUILD_BRANCH }}

    - name: Generate GitHub DASH Token
      run: |
        echo "DASH_RESPONSE=\"foobar_ipsum_lorem\"" >> $GITHUB_ENV
    
    - name: extract and set auth token from DASH JSON response
      id: extract-token
      run: |
        echo "${{ env.DASH_RESPONSE }}"
        echo "AUTH_TOKEN=$(jq -r '.output.token' <<< $DASH_RESPONSE)" >> $GITHUB_ENV
    
    # Ensure we use the DASH token for the npm install process
    - name: Reconfigure git to use HTTP authentication
      run: |
        git config --global url."https://${{ secrets.WP_DASH_USERNAME }}:${{ env.DASH_RESPONSE }}@github.com/rainabba/".insteadOf https://github.com/rainabba/

    - name: Check for changes from this cwd
      run: |
        if [[ $(git diff --name-only --diff-filter=ACMRT $(git tag --sort=committerdate | tail -1) .) != '' ]]; then
          echo "CWD_HAS_CHANGES=true" >> $GITHUB_ENV;
          printf "\n\n\"$(pwd)\" _HAS_CHANGES=true.\n\n";
        else
          echo "CWD_HAS_CHANGES=false" >> $GITHUB_ENV;
          printf "\n\n\"$(pwd)\" _no_changes=true.\n\n";
        fi

    - name: Use Node.js ${{ matrix.node-version }}
      if: env.CWD_HAS_CHANGES
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        check-latest: true

    - name: Run build-serverless.js only for sls mode
      if: env.CWD_HAS_CHANGES && matrix.build-mode == 'sls'
      run: node ./build-serverless.js

    - name: Run npm install
      if: env.CWD_HAS_CHANGES
      run: |
        npm i

    - name: Run npm test
      if: env.CWD_HAS_CHANGES && env.RUN_UNIT_TESTS == 'true'
      run: npm test

    - name: Run test coverage
      if: env.CWD_HAS_CHANGES && env.RUN_TEST_COVERAGE == 'true'
      run: npm run test-coverage

    - name: Run eslint
      if: env.CWD_HAS_CHANGES && env.RUN_ESLINT == 'true'
      run: npm run lint
```

</details>



Discussion / hints:
Hit Ctrl-Enter meaning to provide a new-line as I continued testing, instead is submitted so I apologize in advance if this ends up being needless noise. I've got a reporoducable repo already, but that's allowing me to debug further so perhaps I'll be able to close this soon (with something helpful hopefully).

Fix patch:
diff --git a/pkg/container/docker_run.go b/pkg/container/docker_run.go
index 1948c31719b..0bd67116d96 100644
--- a/pkg/container/docker_run.go
+++ b/pkg/container/docker_run.go
@@ -162,6 +162,9 @@ func (cr *containerReference) CopyDir(destPath string, srcPath string, useGitIgn
 }
 
 func (cr *containerReference) GetContainerArchive(ctx context.Context, srcPath string) (io.ReadCloser, error) {
+	if common.Dryrun(ctx) {
+		return nil, fmt.Errorf("DRYRUN is not supported in GetContainerArchive")
+	}
 	a, _, err := cr.cli.CopyFromContainer(ctx, cr.id, srcPath)
 	return a, err
 }


Test patch: