gcc/libgo
Ian Lance Taylor 421a8ed412 runtime: scan caller-saved registers for non-split-stack
While testing a patch on Solaris, which does not support split-stack, I
    ran across a bug in the handling of caller-saved registers for the
    garbage collector.  For non-split-stack systems, runtime_mcall is
    responsible for saving all caller-saved registers on the stack so that
    the GC stack scan will see them.  It does this by calling
    __builtin_unwind_init and setting the g's gcnextsp field to point to the
    current stack.  The garbage collector then scans the stack from gcnextsp
    to the top of stack.
    
    Unfortunately, the code was setting gcnextsp to point to runtime_mcall's
    argument, which meant that even though runtime_mcall was careful to
    store all caller-saved registers on the stack, the GC never saw them.
    This is, of course, only a problem if a value lives only in a
    caller-saved register, and not anywhere else on the stack or heap.  And
    it is only a problem if that caller-saved register manages to make it
    all the way down to runtime_mcall without being saved by any function on
    the way.  This is moderately unlikely but it turns out that the recent
    changes to keep values on the stack when compiling the runtime package
    caused it to happen for the local variable `s` in `notifyListWait` in
    runtime/sema.go.  That function calls goparkunlock which is simple
    enough to not require all registers, and itself calls runtime_mcall.  So
    it was possible for `s` to be released by the GC before the goroutine
    returned from goparkunlock, which eventually caused a dangling pointer
    to be passed to releaseSudog.
    
    This is not a problem on split-stack systems, which use
    __splitstack_get_context, which saves a stack pointer low enough on the
    stack to scan the registers saved by runtime_mcall.
    
    Reviewed-on: https://go-review.googlesource.com/31323

From-SVN: r241304
2016-10-18 13:29:37 +00:00
..
config libgo: Update libtool support to files in current GCC trunk. 2014-11-12 03:51:36 +00:00
go runtime: copy rdebug code from Go 1.7 runtime 2016-10-17 16:54:25 +00:00
runtime runtime: scan caller-saved registers for non-split-stack 2016-10-18 13:29:37 +00:00
testsuite runtime/internal/sys: new package, API copied from Go 1.7 2016-09-11 13:23:27 +00:00
aclocal.m4 libgo: don't provide ustat on arm64 GNU/Linux 2015-09-15 03:43:01 +00:00
config.h.in runtime: copy internal locking code from Go 1.7 runtime 2016-09-30 13:45:08 +00:00
configure configure: redirect -fsplit-stack compilation to dev/null 2016-10-11 13:13:17 +00:00
configure.ac configure: redirect -fsplit-stack compilation to dev/null 2016-10-11 13:13:17 +00:00
godeps.sh libgo: change build procedure to use build tags 2016-08-06 00:36:33 +00:00
LICENSE
Makefile.am runtime: copy rdebug code from Go 1.7 runtime 2016-10-17 16:54:25 +00:00
Makefile.in runtime: copy rdebug code from Go 1.7 runtime 2016-10-17 16:54:25 +00:00
match.sh libgo: don't unset in shell script 2016-08-13 02:52:42 +00:00
MERGE libgo: update to Go 1.7.1 release 2016-09-10 13:14:00 +00:00
merge.sh libgo: update to go1.7rc3 2016-07-22 18:15:38 +00:00
mkrsysinfo.sh runtime: copy internal locking code from Go 1.7 runtime 2016-09-30 13:45:08 +00:00
mksysinfo.sh syscall, internal/syscall/unix: Fix getrandom, clone on sparc64 2016-10-12 14:28:05 +00:00
mvifdiff.sh runtime: introduce mvifdiff.sh script to replace GCC's move-if-change 2014-12-01 01:06:29 +00:00
PATENTS
README libgo/README: Minor updates. 2015-03-13 18:53:13 +00:00
README.gcc
sysinfo.c runtime: copy internal locking code from Go 1.7 runtime 2016-09-30 13:45:08 +00:00
VERSION libgo: update to Go 1.7.1 release 2016-09-10 13:14:00 +00:00

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.