mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-05 09:44:10 +08:00
f41bf58736
Currently, we dropg (which clears gp.m) after we CAS the g status to _Grunnable or _Gwaiting. Immediately after CASing the g status, another thread may CAS it to _Gscan status and scan its stack. With precise stack scan, it accesses gp.m in order to switch to g and back (in doscanstackswitch). This races with dropg. If doscanstackswitch reads gp.m, then dropg runs, when we restore the m at the end of the scan it will set to a stale value. Worse, if dropg runs after doscanstackswitch sets the new m, gp will be running with a nil m. To fix this, we do dropg before CAS g status to _Grunnable or _Gwaiting. We can do this safely if we are CASing from _Grunning, as we own the g when it is in _Grunning. There is one case where we CAS from _Gsyscall to _Grunnable. It is not safe to dropg when it is in _Gsyscall, as precise stack scan needs to read gp.m in order to signal the m. So we need to introduce a transient state, _Gexitingsyscall, between _Gsyscall and _Grunnable, where the GC should not scan its stack. In is a little unfortunate that we have to add another g status. We could reuse an existing one (e.g. _Gcopystack), but it is clearer and safer to just use a new one, as Austin suggested. Reviewed-on: https://go-review.googlesource.com/c/158157 From-SVN: r268001 |
||
---|---|---|
.. | ||
config | ||
go | ||
misc/cgo | ||
runtime | ||
testsuite | ||
aclocal.m4 | ||
check-packages.txt | ||
config.h.in | ||
configure | ||
configure.ac | ||
goarch.sh | ||
godeps.sh | ||
gotool-packages.txt | ||
libgo-packages.txt | ||
libgo.imp | ||
LICENSE | ||
Makefile.am | ||
Makefile.in | ||
match.sh | ||
MERGE | ||
merge.sh | ||
mkrsysinfo.sh | ||
mkruntimeinc.sh | ||
mksigtab.sh | ||
mksysinfo.sh | ||
mvifdiff.sh | ||
PATENTS | ||
README | ||
README.gcc | ||
sysinfo.c | ||
VERSION |
See ../README. This is the runtime support library for the Go programming language. This library is intended for use with the Go frontend. This library should not be stripped when it is installed. Go code relies on being able to look up file/line information, which comes from the debugging info using the libbacktrace library. The library has only been tested on GNU/Linux using glibc, and on Solaris. It should not be difficult to port to other operating systems. Directories: go A copy of the Go library from http://golang.org/, with several changes for gccgo. runtime Runtime functions, written in C, which are called directly by the compiler or by the library. Contributing ============ To contribute patches to the files in this directory, please see http://golang.org/doc/gccgo_contribute.html . The master copy of these files is hosted at http://code.google.com/p/gofrontend . Changes to these files require signing a Google contributor license agreement. If you are the copyright holder, you will need to agree to the individual contributor license agreement at http://code.google.com/legal/individual-cla-v1.0.html. This agreement can be completed online. If your organization is the copyright holder, the organization will need to agree to the corporate contributor license agreement at http://code.google.com/legal/corporate-cla-v1.0.html. If the copyright holder for your code has already completed the agreement in connection with another Google open source project, it does not need to be completed again.