1
0
mirror of https://github.com/golang/go synced 2024-11-17 15:54:39 -07:00
The Go programming language
Go to file
Russ Cox f95beae61d runtime: use traceback to traverse defer structures
This makes the GC and the stack copying agree about how
to interpret the defer structures. Previously, only the stack
copying treated them precisely.
This removes an untyped memory allocation and fixes
at least three copystack bugs.

To make sure the GC can find the deferred argument
frame until it has been copied, keep a Defer on the defer list
during its execution.

In addition to making it possible to remove the untyped
memory allocation, keeping the Defer on the list fixes
two races between copystack and execution of defers
(in both gopanic and Goexit). The problem is that once
the defer has been taken off the list, a stack copy that
happens before the deferred arguments have been copied
back to the stack will not update the arguments correctly.
The new tests TestDeferPtrsPanic and TestDeferPtrsGoexit
(variations on the existing TestDeferPtrs) pass now but
failed before this CL.

In addition to those fixes, keeping the Defer on the list
helps correct a dangling pointer error during copystack.
The traceback routines walk the Defer chain to provide
information about where a panic may resume execution.
When the executing Defer was not on the Defer chain
but instead linked from the Panic chain, the traceback
had to walk the Panic chain too. But Panic structs are
on the stack and being updated by copystack.
Traceback's use of the Panic chain while copystack is
updating those structs means that it can follow an
updated pointer and find itself reading from the new stack.
The new stack is usually all zeros, so it sees an incorrect
early end to the chain. The new TestPanicUseStack makes
this happen at tip and dies when adjustdefers finds an
unexpected argp. The new StackCopyPoison mode
causes an earlier bad dereference instead.
By keeping the Defer on the list, traceback can avoid
walking the Panic chain at all,  making it okay for copystack
to update the Panics.

We'd have the same problem for any Defers on the stack.
There was only one: gopanic's dabort. Since we are not
taking the executing Defer off the chain, we can use it
to do what dabort was doing, and then there are no
Defers on the stack ever, so it is okay for traceback to use
the Defer chain even while copystack is executing:
copystack cannot modify the Defer chain.

LGTM=khr
R=khr
CC=dvyukov, golang-codereviews, iant, rlh
https://golang.org/cl/141490043
2014-09-16 10:36:38 -04:00
api unicode: strconv: regexp: Upgrade to Unicode 7.0.0. 2014-08-18 20:26:10 +02:00
doc doc: link directly to https://golang.org/dl/ 2014-09-12 09:15:58 +10:00
include runtime: assume precisestack, copystack, StackCopyAlways, ScanStackByFrames 2014-09-09 13:39:57 -04:00
lib codereview: do not hit upload_complete on first patch 2014-08-06 16:12:24 -04:00
misc build: more adjustments for move from src/pkg to src 2014-09-08 00:22:40 -04:00
src runtime: use traceback to traverse defer structures 2014-09-16 10:36:38 -04:00
test cmd/gc: say 'non-constant array bound' instead of 'invalid array bound' 2014-09-16 10:21:54 -04:00
.hgignore build: adjustments for move from src/pkg to src 2014-09-08 00:06:45 -04:00
.hgtags tag go1.3.1 2014-08-13 14:54:54 +10:00
AUTHORS A+C: Michael MacInnis (individual CLA) 2014-09-11 18:35:25 -07:00
CONTRIBUTORS A+C: Michael MacInnis (individual CLA) 2014-09-11 18:35:25 -07:00
favicon.ico
LICENSE
PATENTS
README README: Fix installation instructions 2013-11-20 13:47:37 -08:00
robots.txt

This is the source code repository for the Go programming language.  

For documentation about how to install and use Go,
visit http://golang.org/ or load doc/install-source.html
in your web browser.

After installing Go, you can view a nicely formatted
doc/install-source.html by running godoc --http=:6060
and then visiting http://localhost:6060/doc/install/source.

Unless otherwise noted, the Go source files are distributed
under the BSD-style license found in the LICENSE file.

--

Binary Distribution Notes

If you have just untarred a binary Go distribution, you need to set
the environment variable $GOROOT to the full path of the go
directory (the one containing this README).  You can omit the
variable if you unpack it into /usr/local/go, or if you rebuild
from sources by running all.bash (see doc/install.html).
You should also add the Go binary directory $GOROOT/bin
to your shell's path.

For example, if you extracted the tar file into $HOME/go, you might
put the following in your .profile:

    export GOROOT=$HOME/go
    export PATH=$PATH:$GOROOT/bin

See doc/install.html for more details.