This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libgo patch committed: Don't lose track of m value in GC


The runtime_gc function in libgo invokes the garbage collector proper on
the g0 thread (a thread with a large stack that is not involved in
scheduling).  This is done via runtime_mcall.  Upon return from
runtime_mcall, the caller may be running on a different thread.
Unfortunately, the runtime_gc function called runtime_m to get the Go
thread info, and did not refresh that value after calling
runtime_mcall.  The result mostly worked, but could fail in very busy
program doing lots of work that started going as soon as the GC
stopped.  This patch fixes the problem.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline and 4.9
branch.

Ian

diff -r 52dcc874d3b7 libgo/runtime/mgc0.c
--- a/libgo/runtime/mgc0.c	Wed Aug 13 14:52:52 2014 -0700
+++ b/libgo/runtime/mgc0.c	Fri Aug 15 15:07:02 2014 -0700
@@ -2204,6 +2204,7 @@
 		g->status = Gwaiting;
 		g->waitreason = "garbage collection";
 		runtime_mcall(mgc);
+		m = runtime_m();
 	}
 
 	// all done

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]