<p dir="auto">by <strong>vladimir.webdev</strong>:</p>
<pre class="notranslate">Complete code to reproduce:

package main

import (
       "fmt"
       "websocket"
)

func openConn(ch chan&lt;- int) {
       ws, err := websocket.Dial("ws://localhost:9999/", "", "http://
localhost/")
       if err != nil {
               fmt.Sprintf("Dial: " + err.String())
       }
       defer ws.Close()

       ch &lt;- 1
}

func main() {
       ch := make(chan int)

       for i := 0; i &lt; 1000; i++ {
               go openConn(ch)
       }

       ch &lt;- 1
}

It fails with:

runtime/cgo: pthread_create failed: Resource temporarily unavailable
SIGABRT: abort
PC=0xf97422

Discussion:
<a href="http://groups.google.com/group/golang-nuts/browse_thread/thread/520bdb93d99ee536/a1fdd8c8640cce46#a1fdd8c8640cce46" rel="nofollow">http://groups.google.com/group/golang-nuts/browse_thread/thread/520bdb93d99ee536/a1fdd8c8640cce46#a1fdd8c8640cce46</a>

Quote from 0xe2.0x9a.0...@gmail.com:

The websocket.Dial function is (indirectly) using cgo. Each cgo call
behaves like a syscall. The websocket.Dial() function will try to
allocate C memory when performing address lookup - the memory
allocation (a cgo call) causes the Go runtime to create another OS
thread to handle goroutines. An OS thread (presumably, the newly
created one) calls websocket.Dial() from another goroutine created by
your program, and tries to allocate another piece of C memory, which
in turn creates another OS thread.
This ends up creating too many OS threads.</pre>
<p dir="auto">by <strong><a href="mailto:sarnowski@new-thoughts.org">sarnowski@new-thoughts.org</a></strong>:</p>
<pre class="notranslate">What steps will reproduce the problem?
1. use amd64 OpenBSD-current
1. checkout current tip
2. run the src/all.bash script with bash

What is the expected output?
go builds.


What do you see instead?
Most of the time, the compiler hangs while building the "math" or the
"regex" package. But sometimes I get an error instead:

# Building packages and commands for openbsd/amd64.
runtime
errors
sync/atomic
unicode
math
runtime: split stack overflow: 0x20c8bfe78 &lt; 0x20c8c0000
throw: runtime: split stack overflow

goroutine 1 [syscall]:

goroutine 2 [chan receive]:
main.(*builder).do(0xf8400a9210, 0xf8400a9160, 0xf8400d2c40, 0xf8400a96e0)
        /home/tobias/src/go/src/cmd/go/build.go:532 +0x3ed
main.runInstall(0x691070, 0xf840054230, 0x100000001, 0x0)
        /home/tobias/src/go/src/cmd/go/build.go:180 +0x1cc
main.main()
        /home/tobias/src/go/src/cmd/go/main.go:132 +0x2d8
created by _rt0_amd64
        /home/tobias/src/go/src/pkg/runtime/asm_amd64.s:69 +0xd1

goroutine 3 [runnable]:
syscall.Syscall6()
        /home/tobias/src/go/src/pkg/syscall/asm_openbsd_amd64.s:57 +0x61
syscall.wait4(0x248c, 0xf8401941c0, 0x0, 0xf84010cf30, 0x1, ...)
        /home/tobias/src/go/src/pkg/syscall/zsyscall_openbsd_amd64.go:32 +0x81
syscall.Wait4(0x248c, 0x20c8bf584, 0xf800000000, 0xf84010cf30, 0xf840087d80, ...)
        /home/tobias/src/go/src/pkg/syscall/syscall_bsd.go:136 +0x6a
os.(*Process).Wait(0xf8402254a0, 0x20c8bf660, 0x0, 0x0, 0xf840225c40, ...)
        /home/tobias/src/go/src/pkg/os/exec_unix.go:24 +0xe1
os/exec.(*Cmd).Wait(0xf840236600, 0x0, 0x0, 0x0)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:294 +0x1ba
os/exec.(*Cmd).Run(0xf840236600, 0x55ce08, 0xf840087d20, 0xf8401da690)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:220 +0x6d
main.(*builder).runOut(0xf8400a9210, 0xf8400c6900, 0x22, 0xf840187e91, 0x200000006, ...)
        /home/tobias/src/go/src/cmd/go/build.go:963 +0x17e
main.(*builder).run(0xf8400a9210, 0xf8400c6900, 0x22, 0xf840187e91, 0x6, ...)
        /home/tobias/src/go/src/cmd/go/build.go:930 +0x8d
main.goToolchain.gc(0xf8400a9210, 0xf8400d2540, 0xf840112720, 0x200000023, 0xf840225be0,
...)
        /home/tobias/src/go/src/cmd/go/build.go:1056 +0x782
main.goToolchain.gcÂ·i(0x0, 0xf8400a9210, 0xf8400d2540, 0xf840112720, 0x100000023, ...)
        /home/tobias/src/go/src/cmd/go/bootstrap.go:0 +0xce
main.(*builder).build(0x43d0b7, 0xf8401192c0, 0xf8402ca1c0, 0x0, 0x206, ...)
        /home/tobias/src/go/src/cmd/go/build.go:604 +0x8aa
created by main.(*builder).do
        /home/tobias/src/go/src/cmd/go/build.go:529 +0x3bf

goroutine 4 [runnable]:
syscall.Syscall()
        /home/tobias/src/go/src/pkg/syscall/asm_openbsd_amd64.s:34 +0x5b
syscall.Open(0x5a01f4, 0x9, 0x10000, 0xf840194320, 0x0, ...)
        /home/tobias/src/go/src/pkg/syscall/zsyscall_openbsd_amd64.go:738 +0x71
os.OpenFile(0x5a01f4, 0x100000009, 0x0, 0xf8402ecc00, 0x0, ...)
        /home/tobias/src/go/src/pkg/os/file_unix.go:66 +0x67
os.Open(0x5a01f4, 0x7665642f00000009, 0x2050d5fb0, 0x0, 0x0, ...)
        /home/tobias/src/go/src/pkg/os/file.go:230 +0x54
os/exec.(*Cmd).stdin(0xf8402cb200, 0x0, 0x0, 0x0, 0x1d000001c0, ...)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:145 +0x8a
os/exec.(*Cmd).Start(0xf8402cb200, 0x0, 0x0, 0x20c8c0700)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:234 +0x1fb
os/exec.(*Cmd).Run(0xf8402cb200, 0x55ce08, 0xf8403a2b40, 0xf8401da690)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:217 +0x25
main.(*builder).runOut(0xf8400a9210, 0xf8401a6ed0, 0x20, 0xf84007a989, 0x200000004, ...)
        /home/tobias/src/go/src/cmd/go/build.go:963 +0x17e
main.(*builder).run(0xf8400a9210, 0xf8401a6ed0, 0x20, 0xf84007a989, 0x4, ...)
        /home/tobias/src/go/src/cmd/go/build.go:930 +0x8d
main.goToolchain.gc(0xf8400a9210, 0xf8401068c0, 0xf8400c4660, 0x200000021, 0xf840233c80,
...)
        /home/tobias/src/go/src/cmd/go/build.go:1056 +0x782
main.goToolchain.gcÂ·i(0x0, 0xf8400a9210, 0xf8401068c0, 0xf8400c4660, 0x200000021, ...)
        /home/tobias/src/go/src/cmd/go/bootstrap.go:0 +0xce
main.(*builder).build(0xf8400a9210, 0xf8402d9840, 0x20c8c0f00, 0x40fda2, 0x4fdb78, ...)
        /home/tobias/src/go/src/cmd/go/build.go:604 +0x8aa
main._func_004(0xf840147d98, 0xf840147da0, 0xf840147db8, 0x427c60, 0xf8402d9840, ...)
        /home/tobias/src/go/src/cmd/go/build.go:478 +0x2ff
main._func_005(0xf840147d98, 0xf840147238, 0x0, 0x0)
        /home/tobias/src/go/src/cmd/go/build.go:527 +0xc0
created by main.(*builder).do
        /home/tobias/src/go/src/cmd/go/build.go:529 +0x3bf

goroutine 5 [syscall]:
syscall.Syscall6()
        /home/tobias/src/go/src/pkg/syscall/asm_openbsd_amd64.s:38 +0x5
syscall.wait4(0x610d, 0xf840194420, 0x0, 0xf8402c7090, 0x1, ...)
        /home/tobias/src/go/src/pkg/syscall/zsyscall_openbsd_amd64.go:32 +0x81
syscall.Wait4(0x610d, 0x20c8c1584, 0xf800000000, 0xf8402c7090, 0xf8403a2d20, ...)
        /home/tobias/src/go/src/pkg/syscall/syscall_bsd.go:136 +0x6a
os.(*Process).Wait(0xf840225660, 0x20c8c1660, 0x0, 0x0, 0xf8402259c0, ...)
        /home/tobias/src/go/src/pkg/os/exec_unix.go:24 +0xe1
os/exec.(*Cmd).Wait(0xf840236700, 0x0, 0x0, 0x0)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:294 +0x1ba
os/exec.(*Cmd).Run(0xf840236700, 0x55ce08, 0xf840087060, 0xf8401da690)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:220 +0x6d
main.(*builder).runOut(0xf8400a9210, 0xf8400edf60, 0x27, 0xf8401878a1, 0x20000000b, ...)
        /home/tobias/src/go/src/cmd/go/build.go:963 +0x17e
main.(*builder).run(0xf8400a9210, 0xf8400edf60, 0x27, 0xf8401878a1, 0xb, ...)
        /home/tobias/src/go/src/cmd/go/build.go:930 +0x8d
main.goToolchain.gc(0xf8400a9210, 0xf840106000, 0xf8401feb10, 0x200000028, 0xf840225900,
...)
        /home/tobias/src/go/src/cmd/go/build.go:1056 +0x782
main.goToolchain.gcÂ·i(0x0, 0xf8400a9210, 0xf840106000, 0xf8401feb10, 0x200000028, ...)
        /home/tobias/src/go/src/cmd/go/bootstrap.go:0 +0xce
main.(*builder).build(0xf8400a9210, 0xf8402d9000, 0x20c8c1f00, 0x40fda2, 0x4fdb78, ...)
        /home/tobias/src/go/src/cmd/go/build.go:604 +0x8aa
main._func_004(0xf840147d98, 0xf840147da0, 0xf840147db8, 0x427c60, 0xf8402d9000, ...)
        /home/tobias/src/go/src/cmd/go/build.go:478 +0x2ff
main._func_005(0xf840147d98, 0xf840147238, 0x0, 0x0)
        /home/tobias/src/go/src/cmd/go/build.go:527 +0xc0
created by main.(*builder).do
        /home/tobias/src/go/src/cmd/go/build.go:529 +0x3bf

goroutine 6 [runnable]:
syscall.Syscall()
        /home/tobias/src/go/src/pkg/syscall/asm_openbsd_amd64.s:34 +0x5b
syscall.Close(0x8, 0x0, 0x0, 0xf8402a3000)
        /home/tobias/src/go/src/pkg/syscall/zsyscall_openbsd_amd64.go:337 +0x54
syscall.forkExec(0xf840355810, 0xf80000002d, 0xf8402cb100, 0x100000000c, 0xf840260980,
...)
        /home/tobias/src/go/src/pkg/syscall/exec_unix.go:173 +0x492
syscall.StartProcess(0xf840355810, 0xf80000002d, 0xf8402cb100, 0x100000000c,
0xf840260980, ...)
        /home/tobias/src/go/src/pkg/syscall/exec_unix.go:212 +0x76
os.StartProcess(0xf840355810, 0x2d, 0xf8402cb100, 0x100000000c, 0xf8402aee00, ...)
        /home/tobias/src/go/src/pkg/os/exec_posix.go:43 +0x307
os/exec.(*Cmd).Start(0xf8402cb000, 0x0, 0x0, 0x20c8c2700)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:248 +0x4a7
os/exec.(*Cmd).Run(0xf8402cb000, 0x55ce08, 0xf8402cfcc0, 0xf8401da690)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:217 +0x25
main.(*builder).runOut(0xf8400a9210, 0xf8400ed4e0, 0x23, 0xf840187aa1, 0x200000007, ...)
        /home/tobias/src/go/src/cmd/go/build.go:963 +0x17e
main.(*builder).run(0xf8400a9210, 0xf8400ed4e0, 0x23, 0xf840187aa1, 0x7, ...)
        /home/tobias/src/go/src/cmd/go/build.go:930 +0x8d
main.goToolchain.gc(0xf8400a9210, 0xf8401061c0, 0xf8401bb240, 0x200000024, 0xf8402255a0,
...)
        /home/tobias/src/go/src/cmd/go/build.go:1056 +0x782
main.goToolchain.gcÂ·i(0x0, 0xf8400a9210, 0xf8401061c0, 0xf8401bb240, 0x100000024, ...)
        /home/tobias/src/go/src/cmd/go/bootstrap.go:0 +0xce
main.(*builder).build(0xf8400a9210, 0xf8402d92c0, 0x20c8c2f00, 0x40fda2, 0x4fdb78, ...)
        /home/tobias/src/go/src/cmd/go/build.go:604 +0x8aa
main._func_004(0xf840147d98, 0xf840147da0, 0xf840147db8, 0x427c60, 0xf8402d92c0, ...)
        /home/tobias/src/go/src/cmd/go/build.go:478 +0x2ff
main._func_005(0xf840147d98, 0xf840147238, 0x0, 0x0)
        /home/tobias/src/go/src/cmd/go/build.go:527 +0xc0
created by main.(*builder).do
        /home/tobias/src/go/src/cmd/go/build.go:529 +0x3bf
goroutine 49 [runnable]:
syscall.Syscall()
        /home/tobias/src/go/src/pkg/syscall/asm_openbsd_amd64.s:34 +0x5b
syscall.Read(0x5, 0xf840191800, 0x20000000200, 0x0, 0x0, ...)
        /home/tobias/src/go/src/pkg/syscall/zsyscall_openbsd_amd64.go:800 +0x78
os.(*File).read(0xf840194148, 0xf840191800, 0x20000000200, 0x500b48, 0x0, ...)
        /home/tobias/src/go/src/pkg/os/file_unix.go:163 +0x58
os.(*File).Read(0xf840194148, 0xf840191800, 0x20000000200, 0x0, 0x0, ...)
        /home/tobias/src/go/src/pkg/os/file.go:95 +0x83
bytes.(*Buffer).ReadFrom(0xf840087d20, 0xf8400b2090, 0xf840194148, 0x0, 0x0, ...)
        /home/tobias/src/go/src/pkg/bytes/buffer.go:153 +0x199
io.Copy(0xf8401da690, 0xf840087d20, 0xf8400b2090, 0xf840194148, 0x0, ...)
        /home/tobias/src/go/src/pkg/io/io.go:333 +0xc2
os/exec._func_003(0xf840288130, 0xf840194138, 0x463656, 0x500ed0, 0x4391e2, ...)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:201 +0x5a
os/exec._func_004(0xf840194118, 0xf84028df80, 0x0, 0x0)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:260 +0x1e
created by os/exec.(*Cmd).Start
        /home/tobias/src/go/src/pkg/os/exec/exec.go:261 +0x661

goroutine 50 [runnable]:
syscall.Syscall()
        /home/tobias/src/go/src/pkg/syscall/asm_openbsd_amd64.s:34 +0x5b
syscall.Read(0x7, 0xf840091000, 0x20000000200, 0x0, 0x0, ...)
        /home/tobias/src/go/src/pkg/syscall/zsyscall_openbsd_amd64.go:800 +0x78
os.(*File).read(0xf840194238, 0xf840091000, 0x20000000200, 0x500b48, 0x0, ...)
        /home/tobias/src/go/src/pkg/os/file_unix.go:163 +0x58
os.(*File).Read(0xf840194238, 0xf840091000, 0x20000000200, 0x0, 0x0, ...)
        /home/tobias/src/go/src/pkg/os/file.go:95 +0x83
bytes.(*Buffer).ReadFrom(0xf840087060, 0xf8400b2090, 0xf840194238, 0x0, 0x0, ...)
        /home/tobias/src/go/src/pkg/bytes/buffer.go:153 +0x199
io.Copy(0xf8401da690, 0xf840087060, 0xf8400b2090, 0xf840194238, 0x0, ...)
        /home/tobias/src/go/src/pkg/io/io.go:333 +0xc2
os/exec._func_003(0xf840288500, 0xf840194228, 0x463656, 0xf0, 0x401e6f78, ...)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:201 +0x5a
os/exec._func_004(0xf8401941b0, 0xf8402abc80, 0x0, 0x0)
        /home/tobias/src/go/src/pkg/os/exec/exec.go:260 +0x1e
created by os/exec.(*Cmd).Start
        /home/tobias/src/go/src/pkg/os/exec/exec.go:261 +0x661


Which operating system are you using?
OpenBSD-current (5.1 beta, current publicly available snapshot will do it)
<a href="http://ftp.openbsd.org/pub/OpenBSD/snapshots/amd64/" rel="nofollow">http://ftp.openbsd.org/pub/OpenBSD/snapshots/amd64/</a>

Which revision are you using?  (hg identify)
$ hg identify
a45cc1950c26 tip</pre>