f1857c6369
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 |
||
---|---|---|
config | ||
contrib | ||
fixincludes | ||
gcc | ||
gnattools | ||
gotools | ||
include | ||
INSTALL | ||
intl | ||
libada | ||
libatomic | ||
libbacktrace | ||
libcc1 | ||
libcilkrts | ||
libcpp | ||
libdecnumber | ||
libffi | ||
libgcc | ||
libgfortran | ||
libgo | ||
libgomp | ||
libhsail-rt | ||
libiberty | ||
libitm | ||
libmpx | ||
libobjc | ||
liboffloadmic | ||
libquadmath | ||
libsanitizer | ||
libssp | ||
libstdc++-v3 | ||
libvtv | ||
lto-plugin | ||
maintainer-scripts | ||
zlib | ||
.dir-locals.el | ||
.gitattributes | ||
.gitignore | ||
ABOUT-NLS | ||
ChangeLog | ||
ChangeLog.jit | ||
ChangeLog.tree-ssa | ||
compile | ||
config-ml.in | ||
config.guess | ||
config.rpath | ||
config.sub | ||
configure | ||
configure.ac | ||
COPYING | ||
COPYING3 | ||
COPYING3.LIB | ||
COPYING.LIB | ||
COPYING.RUNTIME | ||
depcomp | ||
install-sh | ||
libtool-ldflags | ||
libtool.m4 | ||
lt~obsolete.m4 | ||
ltgcc.m4 | ||
ltmain.sh | ||
ltoptions.m4 | ||
ltsugar.m4 | ||
ltversion.m4 | ||
MAINTAINERS | ||
Makefile.def | ||
Makefile.in | ||
Makefile.tpl | ||
missing | ||
mkdep | ||
mkinstalldirs | ||
move-if-change | ||
README | ||
symlink-tree | ||
ylwrap |
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.