Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(19)

Delta Between Two Patch Sets: src/pkg/runtime/stack.c

Issue 140950043: code review 140950043: runtime: make entersyscall/exitsyscall safe for stack splits (Closed)
Left Patch Set: Created 10 years, 6 months ago
Right Patch Set: diff -r bd3a9091e8dabd996cc36d5fc63c7aa0fcc581d6 https://code.google.com/p/go/ Created 10 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/runtime.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include "runtime.h" 5 #include "runtime.h"
6 #include "arch_GOARCH.h" 6 #include "arch_GOARCH.h"
7 #include "malloc.h" 7 #include "malloc.h"
8 #include "stack.h" 8 #include "stack.h"
9 #include "funcdata.h" 9 #include "funcdata.h"
10 #include "typekind.h" 10 #include "typekind.h"
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 bool newstackcall; 869 bool newstackcall;
870 870
871 if(g->m->forkstackguard) 871 if(g->m->forkstackguard)
872 runtime·throw("split stack after fork"); 872 runtime·throw("split stack after fork");
873 if(g->m->morebuf.g != g->m->curg) { 873 if(g->m->morebuf.g != g->m->curg) {
874 runtime·printf("runtime: newstack called from g=%p\n" 874 runtime·printf("runtime: newstack called from g=%p\n"
875 "\tm=%p m->curg=%p m->g0=%p m->gsignal=%p\n", 875 "\tm=%p m->curg=%p m->g0=%p m->gsignal=%p\n",
876 g->m->morebuf.g, g->m, g->m->curg, g->m->g0, g->m->gsign al); 876 g->m->morebuf.g, g->m, g->m->curg, g->m->g0, g->m->gsign al);
877 runtime·throw("runtime: wrong goroutine in newstack"); 877 runtime·throw("runtime: wrong goroutine in newstack");
878 } 878 }
879 if(g->throwsplit)
880 runtime·throw("runtime: stack split at bad time");
879 881
880 // The goroutine must be executing in order to call newstack, so the pos sible states are 882 // The goroutine must be executing in order to call newstack, so the pos sible states are
881 // Grunning and Gsyscall (and, due to GC, also Gscanrunning and Gscansys call).·· 883 // Grunning and Gsyscall (and, due to GC, also Gscanrunning and Gscansys call).··
882 884
883 // gp->status is usually Grunning, but it could be Gsyscall if a stack o verflow 885 // gp->status is usually Grunning, but it could be Gsyscall if a stack o verflow
884 // happens during a function call inside entersyscall. 886 // happens during a function call inside entersyscall.
885 gp = g->m->curg; 887 gp = g->m->curg;
886 oldstatus = runtime·readgstatus(gp) & ~Gscan; 888 oldstatus = runtime·readgstatus(gp) & ~Gscan;
887 framesize = g->m->moreframesize; 889 framesize = g->m->moreframesize;
888 argsize = g->m->moreargsize; 890 argsize = g->m->moreargsize;
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
1115 if(gp->m != nil && gp->m->libcallsp != 0) 1117 if(gp->m != nil && gp->m->libcallsp != 0)
1116 return; 1118 return;
1117 #endif 1119 #endif
1118 if(StackDebug > 0) 1120 if(StackDebug > 0)
1119 runtime·printf("shrinking stack %D->%D\n", (uint64)oldsize, (uin t64)newsize); 1121 runtime·printf("shrinking stack %D->%D\n", (uint64)oldsize, (uin t64)newsize);
1120 nframes = copyabletopsegment(gp); 1122 nframes = copyabletopsegment(gp);
1121 if(nframes == -1) 1123 if(nframes == -1)
1122 return; 1124 return;
1123 copystack(gp, nframes, newsize); 1125 copystack(gp, nframes, newsize);
1124 } 1126 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b