This patch from Peter Collingbourne marks runtime_goexit as noinline.
If we don't do that, it may be inlined into the kickoff function.  That
function refers to the TLS variable g, as does runtime_goexit.  But by
the time kickoff calls runtime_goexit, it may be running in a different
thread.  If the address of g is cached, and runtime_goexit is inlined
into kickoff, then then the fetch of g in runtime_goexit may get the
value from the wrong thread.  Bootstrapped and ran Go testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian

diff -r 8aa5c486a3af libgo/runtime/proc.c
--- a/libgo/runtime/proc.c	Mon Sep 22 13:17:47 2014 -0700
+++ b/libgo/runtime/proc.c	Mon Sep 22 14:00:38 2014 -0700
@@ -1894,6 +1894,7 @@
 // Need to mark it as nosplit, because it runs with sp > stackbase (as runtime_lessstack).
 // Since it does not return it does not matter.  But if it is preempted
 // at the split stack check, GC will complain about inconsistent sp.
+void runtime_goexit(void) __attribute__ ((noinline));
 void
 runtime_goexit(void)
 {

Reply via email to