ARTICLE AD BOX
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 FAILMy .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 buildWhat 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
What typically causes this kind of ThreadSanitizer allocation error (errno: 12) on Linux in GitHub Actions?
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)?
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?
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.
