go/misc/cgo
David Crawshaw 3b22ffc07e runtime: make cgocallback wait on package init
With the new buildmodes c-archive and c-shared, it is possible for a
cgo call to come in early in the lifecycle of a Go program. Calls
before the runtime has been initialized are caught by
_cgo_wait_runtime_init_done. However a call can come in after the
runtime has initialized, but before the program's package init
functions have finished running.

To avoid this cgocallback checks m.ncgo to see if we are on a thread
running Go. If not, we may be a foreign thread and it blocks until
main_init is complete.

Change-Id: I7a9f137fa2a40c322a0b93764261f9aa17fcf5b8
Reviewed-on: https://go-review.googlesource.com/8897
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2015-04-14 13:39:02 +00:00
..
errors build: convert run.bash, run.bat, and run.rc into a Go program 2015-03-03 23:22:11 +00:00
gmp misc/cgo/gmp: fix typo. 2013-03-30 19:02:14 +08:00
life misc/cgo: prepare for 64-bit ints 2012-09-24 14:58:45 -04:00
nocgo cmd/ld: really import runtime/cgo for external link 2014-05-20 21:36:50 -07:00
stdio misc/cgo/stdio: make it work on Windows and also test it 2012-09-20 00:27:23 +08:00
test misc/cgo/test/issue9400: add arm64 implementation 2015-04-08 09:08:40 +00:00
testasan runtime: more flexible heap memory mapping on 64-bits 2013-06-12 18:47:16 +04:00
testcarchive runtime: make cgocallback wait on package init 2015-04-14 13:39:02 +00:00
testgodefs build: convert run.bash, run.bat, and run.rc into a Go program 2015-03-03 23:22:11 +00:00
testso Revert "misc/cgo/testso: add test for fixed issue 4339" 2015-04-07 11:50:28 +00:00
testtls misc/cgo/testtls: make test less flaky 2014-01-21 19:44:51 -05:00