Go to file
Ian Lance Taylor 9c48398f49 runtime: Fix GC bug caused by Entersyscall modifying reg.
This patch fixes a rare but serious bug.  The Go garbage
collector only examines Go stacks.  When Go code calls a
function that is not written in Go, it first calls
syscall.Entersyscall.  Entersyscall records the position of
the Go stack pointer and saves a copy of all the registers.
If the garbage collector runs while the thread is executing
the non-Go code, the garbage collector fetches the stack
pointer and registers from the saved location.

Entersyscall saves the registers using the getcontext
function.  Unfortunately I didn't consider the possibility
that Entersyscall might itself change a register before
calling getcontext.  This only matters for callee-saved
registers, as caller-saved registers would be visible on the
saved stack.  And it only matters if Entersyscall is compiled
to save and modify a callee-saved register before it calls
getcontext.  And it only matters if a garbage collection
occurs while the non-Go code is executing.  And it only
matters if the only copy of a valid Go pointer happens to be
in the callee-saved register when Entersyscall is called.
When all those conditions are true, the Go pointer might get
collected incorrectly, leading to memory corruption.

This patch tries to avoid the problem by splitting
Entersyscall into two functions.  The first is a simple
function that just calls getcontext and then calls the rest of
Entersyscall.  This should fix the problem, provided the
simple Entersyscall function does not itself modify any
callee-saved registers before calling getcontext.  That seems
to be true on the systems I checked.  But since the argument
to getcontext is an offset from a TLS variable, it won't be
true on a system which needs to save callee-saved registers in
order to get the address of a TLS variable.  I don't know why
any system would work that way, but I don't know how to rule
it out.  I think that on any such system this will have to be
implemented in assembler.  I can't put the ucontext_t
structure on the stack, because this function can not split
stacks, and the ucontext_t structure is large enough that it
could cause a stack overflow.

From-SVN: r208390
2014-03-07 05:04:37 +00:00
INSTALL README: Also refer to the online installation instructions. 2012-08-25 20:48:20 +00:00
boehm-gc gcconfig.h: Add FreeBSD powerpc64 defines. 2013-12-21 21:42:39 +01:00
config bootstrap-ubsan.mk (POSTSTAGE1_LDFLAGS): Remove -lpthread -ldl. 2013-11-29 20:13:45 +00:00
contrib TILE-Gx big endian support. 2014-02-24 15:08:00 +00:00
fixincludes fixincludes: use $(FI) instead of fixincl@EXEEXT@ 2013-12-20 13:07:52 +01:00
gcc Daily bump. 2014-03-07 00:16:53 +00:00
gnattools Makefile.in (TOOLS_FLAGS_TO_PASS_CROSS): Robustify. 2014-02-23 16:30:11 +00:00
include include 2014-01-21 15:09:10 +00:00
intl
libada Update copyright years in libada/ 2014-01-02 22:24:25 +00:00
libatomic re PR c++/60272 (atomic<>::compare_exchange_weak has spurious store and can cause race conditions) 2014-02-20 09:43:53 -08:00
libbacktrace re PR libgcc/58710 (HAVE_GETIPINFO is incorrectly set on Mac OS X 10.4) 2014-02-07 21:10:55 +00:00
libcilkrts + * include/cilk/common.h (__CILKRTS_ABI_VERSION): Set the ABI version + to 1 instead of 0. 2014-02-18 19:43:21 -08:00
libcpp be.po, [...]: Update. 2014-03-03 19:04:36 +00:00
libdecnumber re PR c/59871 (No unused value warning for comma expression) 2014-01-23 19:04:29 +00:00
libffi re PR libffi/60073 (64-bit libffi.call/cls_double_va.c FAILs after recent modification) 2014-02-17 12:00:04 +00:00
libgcc Don't install vtv_*.o unless --enable-vtable-verify (PR libgcc/59339) 2014-03-06 12:24:11 +00:00
libgfortran re PR fortran/60148 (strings in NAMELIST do not honor DELIM= in open statement) 2014-03-04 04:33:40 +00:00
libgo runtime: Fix GC bug caused by Entersyscall modifying reg. 2014-03-07 05:04:37 +00:00
libgomp Update copyright years in libgomp/ 2014-01-02 22:25:54 +00:00
libiberty Avoid "'dc' may be uninitialized" warning. 2014-01-28 20:06:44 +01:00
libitm Make sure that -msse/-mavx are appended at the end 2014-01-13 11:36:17 -08:00
libjava Added forgotten ChangeLog entry. 2014-02-21 11:55:14 +00:00
libobjc Update copyright years in libobjc/ 2014-01-02 22:26:09 +00:00
libquadmath gnat_ugn.texi: Bump @copying's copyright year. 2014-01-02 22:25:41 +01:00
libsanitizer configure.tgt: Unsupported for little endian PowerPC for now. 2014-03-03 20:36:56 +00:00
libssp * ssp.c (fail): Avoid -Wformat-security warning. 2013-12-07 09:10:02 +01:00
libstdc++-v3 [libstdc++,docs] After the latest batch of papers came out I updated the status docs. 2014-03-06 01:31:39 +00:00
libvtv Fix up ChangeLog entries (name, e-mail, formatting, otherwise). 2013-10-23 21:30:54 +00:00
lto-plugin Fix up ChangeLog entries (name, e-mail, formatting, otherwise). 2013-10-23 21:30:54 +00:00
maintainer-scripts re PR other/56653 (Warning when verifying checksums from MD5SUMS file in tarballs) 2014-02-01 12:01:56 +00:00
zlib Add --enable-host-shared configuration option 2013-10-15 20:33:55 +00:00
.dir-locals.el * .dir-locals.el: Add. 2013-10-16 18:25:31 +00:00
.gitignore * .gitignore: Import from gdb repository. 2013-01-10 10:48:46 -05:00
ABOUT-NLS
COPYING
COPYING.LIB
COPYING.RUNTIME
COPYING3
COPYING3.LIB
ChangeLog * MAINTAINERS: Update my email address. 2014-03-04 12:56:10 +00:00
ChangeLog.tree-ssa
MAINTAINERS * MAINTAINERS: Update my email address. 2014-03-04 12:56:10 +00:00
Makefile.def Added Cilk runtime library (libcilkrts) into GCC. 2013-10-29 11:37:47 -07:00
Makefile.in Makefile.in: Regenerate. 2013-11-07 19:09:31 +01:00
Makefile.tpl Makefile.tpl: Fix typo. 2013-11-07 16:08:10 +01:00
README
compile
config-ml.in
config.guess Import from savannah.gnu.org: 2013-10-01 17:50:56 +01:00
config.rpath
config.sub Import from savannah.gnu.org: 2013-10-01 17:50:56 +01:00
configure TILE-Gx big endian support. 2014-02-24 15:08:00 +00:00
configure.ac TILE-Gx big endian support. 2014-02-24 15:08:00 +00:00
depcomp
install-sh
libtool-ldflags
libtool.m4 libtool.m4 (_LT_ENABLE_LOCK <ld -m flags>): Remove non-canonical ppc host match. 2013-09-20 19:17:52 +09:30
ltgcc.m4
ltmain.sh Ensure libgcc_s unwinder is always used on 64-bit Solaris 10+/x86 (PR target/59788) 2014-02-04 09:31:38 +00:00
ltoptions.m4
ltsugar.m4
ltversion.m4
lt~obsolete.m4
missing
mkdep
mkinstalldirs
move-if-change
symlink-tree
ylwrap

README

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.