-5

Post body (StackOverflow / Reddit / etc.)

I’m running Go tests with the race detector in GitHub Actions via Nix, and I always hit a ThreadSanitizer allocation error on Linux runners. On macOS runners the exact same pipeline works fine.

The error:

==5050==ERROR: ThreadSanitizer failed to allocate 0x1fc0000 (33292288) bytes at address caaaab6a0000 (errno: 12) FAIL go.trai.ch/bob/internal/core/domain 0.007s FAIL 

My .github/workflows/ci.yaml currently looks like this:

name: CI on: push: branches: [ main ] pull_request: jobs: test: name: Test on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-22.04, macos-26] steps: - uses: actions/checkout@v6 - uses: DeterminateSystems/nix-installer-action@v21 - uses: DeterminateSystems/magic-nix-cache-action@v13 - name: Check Flake run: nix flake check - name: Run Tests run: nix develop --command go test -v -race ./... - name: Build Binary run: nix build 

What I’m seeing

  • On macOS runner: go test -v -race ./... succeeds.

  • On Ubuntu runner: go test -v -race ./... consistently fails with the ThreadSanitizer “failed to allocate … errno: 12” error above.

  • The failure only happens when using -race.

What I’ve already tried

  • Using different GitHub Actions Ubuntu images:

    • ubuntu-latest

    • ubuntu-22.04

    • ubuntu-24.04

  • Trying different Nix installer actions (e.g. with and without magic-nix-cache).

  • Running the same workflow without any changes to the Go code itself.

  • The problem only appears on Linux CI; locally (including on macOS) go test -race ./... runs fine.

Environment (roughly)

  • Platform: GitHub Actions

  • OS: Ubuntu runners via runs-on: ubuntu-22.04 (and others I tried) and macOS via runs-on: macos-26

  • Package manager: Nix (flakes)

  • Command: nix develop --command go test -v -race ./...

  • Go: installed via Nix (from nixpkgs)

(If it helps, I can add go env output or the exact flake / nix develop setup.)

Questions

  1. What typically causes this kind of ThreadSanitizer allocation error (errno: 12) on Linux in GitHub Actions?

  2. Is this likely:

    • a memory limit issue on the Ubuntu runner,

    • something specific about how Go’s race detector / TSan works on Linux,

    • or related to running Go via Nix (e.g. some Nix sandbox / ulimit / ASLR / address space issue)?

  3. Are there recommended ways to:

    • reduce TSan / -race memory usage in Go tests on CI, or

    • configure GitHub Actions / Nix so that go test -race is less likely to run out of memory?

  4. As a workaround, is it common practice to:

    • run -race only on a subset of packages,

    • or only on macOS runners,

    • or tweak GORACE / GOMAXPROCS / test parallelism for CI?

Any hints on how to debug this further on GitHub Actions (e.g. ulimit checks, environment variables for TSan/Go, Nix options, etc.) or known issues with Go -race + Nix + Ubuntu runners would be really appreciated.

6
  • Please see minimal reproducible example. Commented Nov 23 at 15:02
  • It also begs the question which shell you're using on which OS. bash will be looking for a file called .... zsh will do recursive globbing. Commented Nov 23 at 16:25
  • @tink ... is a Go package wildcard, it’s interpreted by the go tool, not the shell Commented Nov 23 at 22:18
  • Ooooops @Mr_Pink ... how does it get smuggled past the shell? Commented Nov 23 at 23:03
  • It doesn’t need to, because shells don’t interpret ... in a special way within a command, it’s just three . characters Commented Nov 23 at 23:08

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.