Skip to content

Commit 9198ed4

Browse files
committed
runtime: allow copying of onM frame
Currently goroutines in onM can't be copied/shrunk (including the very goroutine that triggers GC). Special case onM to allow copying. LGTM=daniel.morsing, khr R=golang-codereviews, daniel.morsing, khr, rsc CC=golang-codereviews, rlh https://golang.org/cl/124550043
1 parent 266d350 commit 9198ed4

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/pkg/runtime/stack.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ struct CopyableInfo {
399399
};
400400

401401
void runtime·main(void);
402+
void runtime·switchtoM(void(*)(void));
402403

403404
static bool
404405
checkframecopy(Stkframe *frame, void *arg)
@@ -424,6 +425,13 @@ checkframecopy(Stkframe *frame, void *arg)
424425
cinfo->frames++;
425426
return false; // stop traceback
426427
}
428+
if(f->entry == (uintptr)runtime·switchtoM) {
429+
// A special routine at the bottom of stack of a goroutine that does onM call.
430+
// We will allow it to be copied even though we don't
431+
// have full GC info for it (because it is written in asm).
432+
cinfo->frames++;
433+
return true;
434+
}
427435
if(frame->varp != (byte*)frame->sp) { // not in prologue (and has at least one local or outarg)
428436
stackmap = runtime·funcdata(f, FUNCDATA_LocalsPointerMaps);
429437
if(stackmap == nil) {
@@ -648,7 +656,8 @@ adjustframe(Stkframe *frame, void *arg)
648656
f = frame->fn;
649657
if(StackDebug >= 2)
650658
runtime·printf(" adjusting %s frame=[%p,%p] pc=%p continpc=%p\n", runtime·funcname(f), frame->sp, frame->fp, frame->pc, frame->continpc);
651-
if(f->entry == (uintptr)runtime·main)
659+
if(f->entry == (uintptr)runtime·main ||
660+
f->entry == (uintptr)runtime·switchtoM)
652661
return true;
653662
targetpc = frame->continpc;
654663
if(targetpc == 0) {

0 commit comments

Comments
 (0)