public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libgo patch committed: Record g0 top of stack correctly when not split
@ 2012-02-10 16:01 Ian Lance Taylor
  0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2012-02-10 16:01 UTC (permalink / raw)
  To: gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 350 bytes --]

This patch to libgo records the top of the g0 goroutine stack correctly
when not using -fsplit-stack.  Without this patch the garbage collector
would scan beyond the top of the stack when looking at the g0 stack,
which could cause segmentation violations.  Bootstrapped and ran Go
testsuite on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: patch --]
[-- Type: text/x-diff, Size: 680 bytes --]

diff -r 971ec6345e64 libgo/runtime/proc.c
--- a/libgo/runtime/proc.c	Fri Feb 10 07:50:54 2012 -0800
+++ b/libgo/runtime/proc.c	Fri Feb 10 07:52:48 2012 -0800
@@ -909,7 +909,9 @@
 	__splitstack_getcontext(&g->stack_context[0]);
 #else
 	g->gcinitial_sp = ∓
-	g->gcstack_size = StackMin;
+	// Setting gcstack_size to 0 is a marker meaning that gcinitial_sp
+	// is the top of the stack, not the bottom.
+	g->gcstack_size = 0;
 	g->gcnext_sp = ∓
 #endif
 	getcontext(&g->context);
@@ -1267,6 +1269,8 @@
 #else
 		sp = newg->gcinitial_sp;
 		spsize = newg->gcstack_size;
+		if(spsize == 0)
+			runtime_throw("bad spsize in __go_go");
 		newg->gcnext_sp = sp;
 #endif
 	} else {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-02-10 15:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-10 16:01 libgo patch committed: Record g0 top of stack correctly when not split Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).