#81552·Go

runtime/cgo: intermittent `SIGABRT` (pthread_create failed: Resource temporarily unavailable)

Author: askmeaksCreated Sep 15, 2026Updated Sep 28, 2026
LabelsWaitingForInfoNeedsInvestigationcompiler/runtime

Go version

1.26.7

Output of go env in your module/workspace:

bash
[root@736f56403734 go-sl1]# go env
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1782309974=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/dev/go-sl1/go.mod'
GOMODCACHE='/root/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/root/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/golang'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/lib/golang/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.26.7 (Red Hat 1.26.7-1.0.1.module+el8.10.0+91008+b9491da4)'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

Ran a cgo-linked binary (cgo is pulled in transitively via github.com/coreos/go-systemd/v22/internal/dlopen, not via direct import "C" in our own code) repeatedly under normal load. The binary is short-lived (a CLI subcommand that runs, does some work, and exits). No unusual rlimits, cgroup limits, or memory pressure at time of failure — see below.

What did you see happen?

An intermittent, unrecoverable abort during runtime startup, before main() is ever reached:

runtime/cgo: pthread_create failed: Resource temporarily unavailable SIGABRT: abort

goroutine 1 [running, locked to thread]: runtime.systemstack_switch() runtime.newm1(...) runtime.newm(...) runtime.startTemplateThread() runtime.main()

In other captures the failure instead lands slightly later, during the GC-helper goroutine/thread spin-up (still pre-main()), sometimes printing runtime/cgo: pthread_create failed twice in a row before the abort, and in one capture as fatal error: runtime: cannot allocate memory via runtime.(*mheap).allocSpan → runtime.persistentalloc instead of the cgo message.

We ruled out every resource ceiling we could find before concluding this was a runtime issue rather than an environment one, all clean/unremarkable at the moment of failure:

RLIMIT_AS (soft 1GiB, hard unlimited), RLIMIT_NPROC (limit 23454, ~16 threads in use for the whole UID) cgroup v2 memory.max unlimited at every level in the hierarchy; memory.events' max/oom/oom_kill counters all 0 System-wide /proc/meminfo: Committed_AS flat around 2.65GB against a 9.1GB CommitLimit; MemAvailable steady ~4.1GB vm.max_map_count at the 65530 default; single NUMA node, /proc/buddyinfo unremarkable SELinux Permissive (no relevant AVC denials); VMware balloon driver at 0MB; vmstat showing an idle system (90–100% idle CPU, no swap/disk I/O) at time of failure

An strace -f on the parent process showed clone3() succeeding every time; widening the trace to include mmap/mprotect/brk caught a real mmap(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) returning -1 ENOMEM for a just-clone3()'d thread immediately before one of the aborts — i.e. pthread_create's internal stack allocation fails at the mmap() step itself, not at clone3(), despite nothing above showing pressure.

Failure rate was workload-dependent — frequent on a high-invocation-frequency code path, rare on a low-frequency one using identical code and environment — which reads more like a narrow timing window in the runtime's startup thread-creation sequence than a hard resource limit. Pinning the toolchain to go1.25.9 eliminated the failure entirely across 10 consecutive runs of a workload that previously failed on most attempts under 1.26.5/1.26.7.

What did you expect to see?

The process starts and runs normally, as it does under go1.25.9 and as it does most of the time even under go1.26.x.