diff --git a/src/pkg/runtime/race.c b/src/pkg/runtime/race.c index a94298f055..97bfe6864e 100644 --- a/src/pkg/runtime/race.c +++ b/src/pkg/runtime/race.c @@ -92,8 +92,11 @@ runtime·racefuncexit(void) void runtime·racemalloc(void *p, uintptr sz, void *pc) { + // use m->curg because runtime·stackalloc() is called from g0 + if(m->curg == nil) + return; m->racecall = true; - runtime∕race·Malloc(g->goid-1, p, sz, pc); + runtime∕race·Malloc(m->curg->goid-1, p, sz, pc); m->racecall = false; }