[PR #5782] Fix segmentation fault in dry-run mode with service containers #2604

Open
opened 2026-03-01 22:37:24 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/nektos/act/pull/5782
Author: @TheFynx
Created: 6/21/2025
Status: 🔄 Open

Base: masterHead: 2607-services-dry-run


📝 Commits (4)

  • d1314b3 fixed issue with service container dry-run usage
  • c8becd3 cleanup test
  • 3b4ce3a Merge branch 'master' into 2607-services-dry-run
  • d704c91 Merge branch 'nektos:master' into 2607-services-dry-run

📊 Changes

3 files changed (+75 additions, -1 deletions)

View changed files

📝 pkg/container/docker_run.go (+19 -1)
📝 pkg/runner/run_context.go (+8 -0)
pkg/runner/run_context_dryrun_test.go (+48 -0)

📄 Description

Description

Fixes segmentation fault that occurs when running act -n (dry-run mode) with GitHub Actions workflows containing service containers.

Fixes #2607

Problem

When running workflows with service containers in dry-run mode, Act would crash with a segmentation fault at pkg/container/docker_run.go:173 in the GetHealth() method. This happened because:

  1. In dry-run mode, service containers are not actually created (no Docker client connection)
  2. The health checking code still attempted to inspect non-existent containers via cr.cli.ContainerInspect(ctx, cr.id)
  3. This resulted in a nil pointer dereference when cr.cli was nil

Solution

Added dry-run mode protection at two critical points:

  1. GetHealth() method - Returns HealthHealthy immediately in dry-run mode instead of attempting Docker inspection
  2. waitForServiceContainer() function - Skips all health checking in dry-run mode

The fix ensures that act's dry-run mode works consistently with service containers by providing appropriate mock responses instead of attempting real Docker operations.

Testing

  • Added regression test TestServiceContainerWorkflowDryRun to prevent future regressions
  • Manually validated that act -n with service containers no longer crashes
  • All existing service container tests continue to pass:
    • TestRunEvent/services
    • TestRunEvent/services-empty-image
    • TestRunEvent/services-host-network
    • TestRunEvent/services-with-container
    • TestRunEvent/mysql-service-container-with-health-check

Compliance

  • Code formatted with go fmt ./...
  • Ran go mod tidy (why go.mod was altered)
  • Includes test coverage of change

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/nektos/act/pull/5782 **Author:** [@TheFynx](https://github.com/TheFynx) **Created:** 6/21/2025 **Status:** 🔄 Open **Base:** `master` ← **Head:** `2607-services-dry-run` --- ### 📝 Commits (4) - [`d1314b3`](https://github.com/nektos/act/commit/d1314b32526378ca45fead6df8193f0ed4261007) fixed issue with service container dry-run usage - [`c8becd3`](https://github.com/nektos/act/commit/c8becd3717f3ef51fc94b4b2d0d1b93ed43cb4ee) cleanup test - [`3b4ce3a`](https://github.com/nektos/act/commit/3b4ce3a266200f6f7871b3c334b59e733583d4aa) Merge branch 'master' into 2607-services-dry-run - [`d704c91`](https://github.com/nektos/act/commit/d704c91a46e36c56291ed4f0c6352386ae33fc76) Merge branch 'nektos:master' into 2607-services-dry-run ### 📊 Changes **3 files changed** (+75 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `pkg/container/docker_run.go` (+19 -1) 📝 `pkg/runner/run_context.go` (+8 -0) ➕ `pkg/runner/run_context_dryrun_test.go` (+48 -0) </details> ### 📄 Description ## Description Fixes segmentation fault that occurs when running `act -n` (dry-run mode) with GitHub Actions workflows containing service containers. Fixes #2607 ## Problem When running workflows with service containers in dry-run mode, Act would crash with a segmentation fault at `pkg/container/docker_run.go:173` in the `GetHealth()` method. This happened because: 1. In dry-run mode, service containers are not actually created (no Docker client connection) 2. The health checking code still attempted to inspect non-existent containers via `cr.cli.ContainerInspect(ctx, cr.id)` 3. This resulted in a nil pointer dereference when `cr.cli` was nil ## Solution Added dry-run mode protection at two critical points: 1. **`GetHealth()` method** - Returns `HealthHealthy` immediately in dry-run mode instead of attempting Docker inspection 2. **`waitForServiceContainer()` function** - Skips all health checking in dry-run mode The fix ensures that act's dry-run mode works consistently with service containers by providing appropriate mock responses instead of attempting real Docker operations. ## Testing - Added regression test `TestServiceContainerWorkflowDryRun` to prevent future regressions - Manually validated that `act -n` with service containers no longer crashes - All existing service container tests continue to pass: - `TestRunEvent/services` - `TestRunEvent/services-empty-image` - `TestRunEvent/services-host-network` - `TestRunEvent/services-with-container` - `TestRunEvent/mysql-service-container-with-health-check` ## Compliance - [x] Code formatted with `go fmt ./...` - [x] Ran `go mod tidy` (why go.mod was altered) - [x] Includes test coverage of change --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/act#2604
No description provided.