summaryrefslogtreecommitdiff
path: root/src/pkg/runtime/proc.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/pkg/runtime/proc.go')
-rw-r--r--src/pkg/runtime/proc.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/pkg/runtime/proc.go b/src/pkg/runtime/proc.go
index a9cac266b..48b8cbe39 100644
--- a/src/pkg/runtime/proc.go
+++ b/src/pkg/runtime/proc.go
@@ -75,7 +75,19 @@ func acquireSudog() *sudog {
c.sudogcache = s.next
return s
}
- return new(sudog)
+
+ // Delicate dance: the semaphore implementation calls
+ // acquireSudog, acquireSudog calls new(sudog),
+ // new calls malloc, malloc can call the garbage collector,
+ // and the garbage collector calls the semaphore implementation
+ // in stoptheworld.
+ // Break the cycle by doing acquirem/releasem around new(sudog).
+ // The acquirem/releasem increments m.locks during new(sudog),
+ // which keeps the garbage collector from being invoked.
+ mp := acquirem()
+ p := new(sudog)
+ releasem(mp)
+ return p
}
//go:nosplit