1
0
mirror of https://github.com/golang/go synced 2024-11-27 03:31:29 -07:00

[dev.garbage] runtime: concurrent mark fixes

Add missing write barrier when initializing state
for newly created goroutine. Add write barrier for
same slot when preempting a goroutine.

Disable write barrier during goroutine death,
because dopanic does pointer writes.

With concurrent mark enabled (not in this CL), all.bash passed once.
The second time, TestGoexitCrash-2 failed.

LGTM=rlh
R=rlh
CC=golang-codereviews
https://golang.org/cl/167610043
This commit is contained in:
Russ Cox 2014-11-11 16:54:50 -05:00
parent 37186d91fa
commit 9eded54fa3
5 changed files with 13 additions and 3 deletions

View File

@ -1094,8 +1094,7 @@ shade(byte *b)
void void
runtime·gcmarkwb_m() runtime·gcmarkwb_m()
{ {
byte **slot, *ptr; byte *ptr;
slot = (byte**)g->m->scalararg[0];
ptr = (byte*)g->m->scalararg[1]; ptr = (byte*)g->m->scalararg[1];
switch(runtime·gcphase) { switch(runtime·gcphase) {

View File

@ -109,7 +109,7 @@ func writebarrierptr_nostore(dst *uintptr, src uintptr) {
} }
mp := acquirem() mp := acquirem()
if mp.inwb { if mp.inwb || mp.dying > 0 {
releasem(mp) releasem(mp)
return return
} }

View File

@ -1121,6 +1121,8 @@ void runtime·osyield(void);
void runtime·lockOSThread(void); void runtime·lockOSThread(void);
void runtime·unlockOSThread(void); void runtime·unlockOSThread(void);
void runtime·writebarrierptr_nostore(void*, void*);
bool runtime·showframe(Func*, G*); bool runtime·showframe(Func*, G*);
void runtime·printcreatedby(G*); void runtime·printcreatedby(G*);

View File

@ -707,6 +707,14 @@ runtime·newstack(void)
runtime·throw("runtime: split stack overflow"); runtime·throw("runtime: split stack overflow");
} }
if(gp->sched.ctxt != nil) {
// morestack wrote sched.ctxt on its way in here,
// without a write barrier. Run the write barrier now.
// It is not possible to be preempted between then
// and now, so it's okay.
runtime·writebarrierptr_nostore(&gp->sched.ctxt, gp->sched.ctxt);
}
if(gp->stackguard0 == (uintptr)StackPreempt) { if(gp->stackguard0 == (uintptr)StackPreempt) {
if(gp == g->m->g0) if(gp == g->m->g0)
runtime·throw("runtime: preempt g0"); runtime·throw("runtime: preempt g0");

View File

@ -20,6 +20,7 @@ runtime·gostartcall(Gobuf *gobuf, void (*fn)(void), void *ctxt)
gobuf->sp = (uintptr)sp; gobuf->sp = (uintptr)sp;
gobuf->pc = (uintptr)fn; gobuf->pc = (uintptr)fn;
gobuf->ctxt = ctxt; gobuf->ctxt = ctxt;
runtime·writebarrierptr_nostore(&gobuf->ctxt, ctxt);
} }
// Called to rewind context saved during morestack back to beginning of function. // Called to rewind context saved during morestack back to beginning of function.