Commit 8c357ce2 authored by Russ Cox's avatar Russ Cox

fix another gc bug, one that i have only imagined,

not observed: do not use malloc to allocate stacks
during garbage collection, because it would make the
malloc data structures change underfoot.

R=r
DELTA=6  (3 added, 0 deleted, 3 changed)
OCL=30323
CL=30326
parent 36835c7a
......@@ -274,7 +274,7 @@ stackalloc(uint32 n)
uint32 *ref;
//return oldmal(n);
if(m->mallocing) {
if(m->mallocing || m->gcing) {
lock(&stacks);
if(stacks.size == 0)
FixAlloc_Init(&stacks, n, SysAlloc, nil, nil);
......@@ -298,7 +298,7 @@ stackfree(void *v)
{
//return;
if(m->mallocing) {
if(m->mallocing || m->gcing) {
lock(&stacks);
FixAlloc_Free(&stacks, v);
unlock(&stacks);
......
......@@ -215,6 +215,7 @@ gc(int32 force)
if(gcpercent < 0)
return;
m->gcing = 1;
semacquire(&gcsema);
gosave(&g->sched); // update g's stack pointer for scanstack
stoptheworld();
......@@ -228,4 +229,5 @@ gc(int32 force)
starttheworld();
gosave(&g->sched); // update g's stack pointer for debugging
semrelease(&gcsema);
m->gcing = 0;
}
......@@ -177,6 +177,7 @@ struct M
int32 siz2;
int32 id;
int32 mallocing;
int32 gcing;
int32 locks;
Note havenextg;
G* nextg;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment