• Austin Clements's avatar
    runtime: initialize g0 stack bounds on Windows to full stack · 52e782a2
    Austin Clements authored
    Currently, we allocate 1MB or 2MB thread stacks on Windows, but in
    non-cgo binaries still set the g0 stack bounds assuming only 64k is
    available. While this is fine in pure Go binaries, a non-cgo Go binary
    on Windows can use the syscall package to call arbitrary DLLs, which
    may call back into Go. If a DLL function uses more than 64k of stack
    and then calls back into Go, the Go runtime will believe that it's out
    of stack space and crash.
    
    Fix this by plumbing the correct stack size into the g0 stacks of
    non-cgo binaries. Cgo binaries already use the correct size because
    their g0 stack sizes are set by a different code path.
    
    Fixes #20975.
    
    Change-Id: Id6fb559cfe1e1ea0dfac56d4654865c20dccf68d
    Reviewed-on: https://go-review.googlesource.com/120195
    Run-TryBot: Austin Clements <austin@google.com>
    TryBot-Result: Gobot Gobot <gobot@golang.org>
    Reviewed-by: default avatarAlex Brainman <alex.brainman@gmail.com>
    Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
    52e782a2
gcc_windows_amd64.c 1.29 KB