runtime: make SIGPROF skip stacks that are being copied
runtime: make SIGPROF skip stacks that are being copied

sigprof tracebacks the stack across systemstack switches to make
profile tracebacks more complete. However, it does this even if the
user stack is currently being copied, which means it may be in an
inconsistent state that will cause the traceback to panic.

One specific way this can happen is during stack shrinking. Some
goroutine blocks for STW, then enters gchelper, which then assists
with root marking. If that root marking happens to pick the original
goroutine and its stack needs to be shrunk, it will begin to copy that
stack. During this copy, the stack is generally inconsistent and, in
particular, the actual locations of the stack barriers and their
recorded locations are temporarily out of sync. If a SIGPROF happens
during this inconsistency, it will walk the stack all the way back to
the blocked goroutine and panic when it fails to unwind the stack
barriers.

Fix this by disallowing jumping to the user stack during SIGPROF if
that user stack is in the process of being copied.

Fixes #12932.

Change-Id: I9ef694c2c01e3653e292ce22612418dd3daff1b4
Reviewed-on: https://go-review.googlesource.com/16819
Reviewed-by: Daniel Morsing <e6db6d60a117315d4db28c5aa49e186fd9c45709@gmail.com>
Run-TryBot: Austin Clements <7ea35d812706d9213868749011af1ed4fa2f6aa0@google.com>
TryBot-Result: Gobot Gobot <66cb808b70d30c07676d5e946fee83fd561249e5@golang.org>

Samurais/go,nawawi/go,ImJasonH/go,goodlang/good,momchil-velikov/go,kim-racktop/go,ganboing/go-esx,akutz/go,goodlang/good,Cofyc/go,kim-racktop/go,cloudflare/go,rachtsingh/gogojuice,Samurais/go,ImJasonH/go,goodlang/good,theif519/go,4ad/go,binarycrusader/go,nawawi/go,linux-on-ibm-z/go,cyberroadie/go,odeke-em/go,derekmarcotte/go,derekmarcotte/go,fjballest/golang,sndnvaps/go,Jordanzuo/go,ganboing/go-esx,akutz/go,codestation/go,vanloswang/go,polyverse-security/go,christopher-henderson/Go,deft-code/go,roth1002/go,Samurais/go,vanloswang/go,polyverse-security/go,josharian/go,cyberroadie/go,Endika/go,miolini/go,momchil-velikov/go,vanloswang/go,josharian/go,Samurais/go,ImJasonH/go,deft-code/go,cloudflare/go,Jordanzuo/go,ganboing/go-esx,codestation/go,sndnvaps/go,CAFxX/go,CAFxX/go,Endika/go,cyberroadie/go,derekmarcotte/go,CAFxX/go,deft-code/go,linux-on-ibm-z/go,linux-on-ibm-z/go,akutz/go,josharian/go,sndnvaps/go,kim-racktop/go,sndnvaps/go,nawawi/go,vsekhar/elastic-go,vsekhar/elastic-go,codestation/go,golang/go,Jordanzuo/go,mwhudson/go,goodlang/good,fjballest/golang,roth1002/go,CAFxX/go,ganboing/go-esx,theif519/go,theif519/go,deft-code/go,codestation/go,fjballest/golang,Endika/go,ImJasonH/go,momchil-velikov/go,fjballest/golang,odeke-em/go,fjballest/golang,ImJasonH/go,cloudflare/go,Cofyc/go,vsekhar/elastic-go,miolini/go,golang/go,goodlang/good,ganboing/go-esx,cloudflare/go,polyverse-security/go,suncycheng/go,Cofyc/go,binarycrusader/go,cloudflare/go,4ad/go,golang/go,sndnvaps/go,vsekhar/elastic-go,akutz/go,odeke-em/go,kim-racktop/go,miolini/go,vsekhar/elastic-go,deft-code/go,derekmarcotte/go,suncycheng/go,akutz/go,suncycheng/go,miolini/go,goodlang/good,akutz/go,vanloswang/go,theif519/go,binarycrusader/go,deft-code/go,miolini/go,Cofyc/go,Jordanzuo/go,suncycheng/go,fjballest/golang,Cofyc/go,polyverse-security/go,linux-on-ibm-z/go,codestation/go,vanloswang/go,Jordanzuo/go,codestation/go,sndnvaps/go,CAFxX/go,odeke-em/go,4ad/go,Jordanzuo/go,4ad/go,mwhudson/go,cloudflare/go,rachtsingh/gogojuice,odeke-em/go,fjballest/golang,josharian/go,nawawi/go,roth1002/go,josharian/go,Jordanzuo/go,cyberroadie/go,polyverse-security/go,roth1002/go,kim-racktop/go,vanloswang/go,deft-code/go,Endika/go,binarycrusader/go,suncycheng/go,akutz/go,goodlang/good,Endika/go,linux-on-ibm-z/go,miolini/go,kim-racktop/go,Endika/go,josharian/go,polyverse-security/go,momchil-velikov/go,theif519/go,derekmarcotte/go,mwhudson/go,polyverse-security/go,polyverse-security/go,linux-on-ibm-z/go,Samurais/go,ImJasonH/go,nawawi/go,rachtsingh/gogojuice,kim-racktop/go,Samurais/go,4ad/go,miolini/go,josharian/go,mwhudson/go,momchil-velikov/go,cyberroadie/go,miolini/go,deft-code/go,CAFxX/go,derekmarcotte/go,ganboing/go-esx,golang/go,Cofyc/go,mwhudson/go,odeke-em/go,sndnvaps/go,Cofyc/go,cyberroadie/go,4ad/go,theif519/go,4ad/go,linux-on-ibm-z/go,momchil-velikov/go,odeke-em/go,vsekhar/elastic-go,sndnvaps/go,4ad/go,rachtsingh/gogojuice,nawawi/go,golang/go,binarycrusader/go,ganboing/go-esx,CAFxX/go,fjballest/golang,roth1002/go,mwhudson/go,derekmarcotte/go,derekmarcotte/go,binarycrusader/go,Cofyc/go,cloudflare/go,rachtsingh/gogojuice,cloudflare/go,momchil-velikov/go,mwhudson/go,binarycrusader/go,theif519/go,goodlang/good,roth1002/go,Samurais/go,CAFxX/go,linux-on-ibm-z/go,codestation/go,Endika/go,suncycheng/go,codestation/go,nawawi/go,Jordanzuo/go,golang/go,kim-racktop/go,odeke-em/go,cyberroadie/go,roth1002/go,rachtsingh/gogojuice,golang/go,josharian/go,momchil-velikov/go,ImJasonH/go,binarycrusader/go,suncycheng/go,mwhudson/go,Samurais/go,vanloswang/go,roth1002/go,theif519/go,Endika/go,vsekhar/elastic-go,vanloswang/go,nawawi/go,akutz/go,cyberroadie/go,suncycheng/go,rachtsingh/gogojuice,golang/go,vsekhar/elastic-go,rachtsingh/gogojuice,ganboing/go-esx,ImJasonH/go