gcc/libgo/go
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
..
archive libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
bufio libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
builtin libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
bytes Big merge of changes to gofrontend repo that were postponed due to the 2017-05-10 17:26:09 +00:00
cmd cmd/go: don't require GOROOT to exist for gccgo 2017-06-23 20:11:27 +00:00
compress libgo: update to go1.8rc2 2017-01-23 22:18:42 +00:00
container libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
context libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
crypto libgo: update to 1.8.3 release 2017-06-08 19:02:12 +00:00
database/sql libgo: update to 1.8.3 release 2017-06-08 19:02:12 +00:00
debug debug/elf: handle Alpha relocs 2017-06-21 22:39:36 +00:00
encoding libgo: update to Go 1.8.1 release 2017-04-17 22:10:58 +00:00
errors
exp
expvar libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
flag libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
fmt libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
go libgo: remove old MIPS architecture names 2017-06-21 22:11:04 +00:00
golang_org/x syscall, golang_org/x/net/lif: fixes for gccgo on Solaris 2017-01-18 03:37:52 +00:00
hash libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
html libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
image libgo: update to Go 1.8.1 release 2017-04-17 22:10:58 +00:00
index/suffixarray libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
internal Forgot to remove this file in the last libgo commit. 2017-06-21 22:29:36 +00:00
io libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
log libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
math Big merge of changes to gofrontend repo that were postponed due to the 2017-05-10 17:26:09 +00:00
mime Big merge of changes to gofrontend repo that were postponed due to the 2017-05-10 17:26:09 +00:00
net libgo: update to 1.8.3 release 2017-06-08 19:02:12 +00:00
os os: align siginfo argument to waitid 2017-06-23 17:10:18 +00:00
path Big merge of changes to gofrontend repo that were postponed due to the 2017-05-10 17:26:09 +00:00
plugin libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
reflect Big merge of changes to gofrontend repo that were postponed due to the 2017-05-10 17:26:09 +00:00
regexp libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
runtime runtime: complete defer handling in CgocallBackDone 2017-06-23 20:19:40 +00:00
sort libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
strconv libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
strings libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
sync libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00
syscall libgo: remove old MIPS architecture names 2017-06-21 22:11:04 +00:00
testing libgo: update to final Go 1.8 release 2017-02-17 15:43:39 +00:00
text libgo: update to Go 1.8.1 release 2017-04-17 22:10:58 +00:00
time Big merge of changes to gofrontend repo that were postponed due to the 2017-05-10 17:26:09 +00:00
unicode libgo: update to Go 1.8 release candidate 1 2017-01-14 00:05:42 +00:00