gcc/libgo
Ian Lance Taylor f1857c6369 runtime: complete defer handling in CgocallBackDone
When C code calls a Go function, it actually calls a function
    generated by cgo. That function is written in Go, and, among other
    things, it calls the real Go function like this:
            CgocallBack()
            defer CgocallBackDone()
            RealGoFunction()
    The deferred CgocallBackDone function enters syscall mode as we return
    to C. Typically the C function will then eventually return to Go.
    
    However, in the case where the C function is running on a thread
    created in C, it will not return to Go. For that case we will have
    allocated an m struct, with an associated g struct, for the duration
    of the Go code, and when the Go is complete we will return the m and g
    to a free list.
    
    That all works, but we are running in a deferred function, which means
    that we have been invoked by deferreturn, and deferreturn expects to
    do a bit of cleanup to record that the defer has been completed. Doing
    that cleanup while using an m and g that have already been returned to
    the free list is clearly a bad idea. It was kind of working because
    deferreturn was holding the g pointer in a local variable, but there
    were races with some other thread picking up and using the newly freed g.
    It was also kind of working because of a special check in freedefer;
    that check is no longer necessary.
    
    This patch changes the special case of releasing the m and g to do the
    defer cleanup in CgocallBackDone itself.
    
    This patch also checks for the special case of a panic through
    CgocallBackDone. In that special case, we don't want to release the m
    and g. Since we are returning to C code that was not called by Go
    code, we know that the panic is not going to be caught and we are
    going to exit the program. So for that special case we keep the m and
    g structs so that the rest of the panic code can use them.
    
    Reviewed-on: https://go-review.googlesource.com/46530

From-SVN: r249611
2017-06-23 20:19:40 +00:00
..
config libgo: Update libtool support to files in current GCC trunk. 2014-11-12 03:51:36 +00:00
go runtime: complete defer handling in CgocallBackDone 2017-06-23 20:19:40 +00:00
runtime runtime: fix type cast in assignment to gcnextsp in C code 2017-06-22 19:52:11 +00:00
testsuite libgo: remove old MIPS architecture names 2017-06-21 22:11:04 +00:00
aclocal.m4 libgo: fixes for Solaris build 2016-12-13 18:03:45 +00:00
config.h.in libgo, syscall: fix ptrace implementation on MIPS 2017-06-21 21:42:41 +00:00
configure libgo: remove old MIPS architecture names 2017-06-21 22:11:04 +00:00
configure.ac libgo: remove old MIPS architecture names 2017-06-21 22:11:04 +00:00
godeps.sh libgo: change build procedure to use build tags 2016-08-06 00:36:33 +00:00
libgo.imp Big merge of changes to gofrontend repo that were postponed due to the 2017-05-10 17:26:09 +00:00
LICENSE
Makefile.am libgo: support for sparc64 GNU/Linux 2017-05-31 21:36:42 +00:00
Makefile.in libgo: support for sparc64 GNU/Linux 2017-05-31 21:36:42 +00:00
match.sh libgo: remove old MIPS architecture names 2017-06-21 22:11:04 +00:00
MERGE libgo: update to 1.8.3 release 2017-06-08 19:02:12 +00:00
merge.sh libgo: update to go1.8rc3 2017-01-27 15:01:57 +00:00
mkrsysinfo.sh libgo: support for sparc64 GNU/Linux 2017-05-31 21:36:42 +00:00
mksigtab.sh mksigtab.sh: recurse once when adding signals to SIGLIST 2017-05-12 01:09:42 +00:00
mksysinfo.sh libgo, syscall: fix ptrace implementation on MIPS 2017-06-21 21:42:41 +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 libgo, syscall: fix ptrace implementation on MIPS 2017-06-21 21:42:41 +00:00
VERSION libgo: update to 1.8.3 release 2017-06-08 19:02:12 +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.