Skip to content
Latchkey

Go cgo "exec gcc: signal: killed" (OOM) - Fix in CI

cgo spawns gcc/clang to compile the C side of a package. A large translation unit on a small runner can exhaust RAM, and the kernel OOM killer sends SIGKILL - surfacing as "signal: killed".

What this error means

A cgo build fails with exec: "gcc": signal: killed or the compiler dies with no diagnostic. Memory pressure on a small runner caused the kernel to kill the compiler process.

go
# example.com/app/native
cgo: C compiler "gcc" failed: exit status 1
exec: "gcc": signal: killed

Common causes

Runner ran out of memory

A heavy C compilation exceeded available RAM and the OOM killer terminated gcc with SIGKILL.

Too much build parallelism

Many gcc processes ran at once via -p, multiplying peak memory beyond what the runner has.

How to fix it

Lower build parallelism

  1. Cap the number of concurrent compile actions so peak memory stays bounded.
shell
go build -p 2 ./...

Build on a larger runner

  1. Move the cgo-heavy job to a runner with more RAM so the compiler is not killed.
.github/workflows/ci.yml
jobs:
  build:
    runs-on: latchkey-large

How to prevent it

  • Size cgo-heavy jobs onto runners with adequate RAM.
  • Cap -p so concurrent gcc processes do not multiply memory use.
  • Watch peak memory of native builds and split large C units.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →