aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/malloc.go
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2022-07-20 15:06:31 -0400
committerAustin Clements <austin@google.com>2022-08-04 15:31:46 +0000
commitd29a0282e9b7340ba2ed3f506e66304e92580238 (patch)
tree2be3cf0a6a7dee0569fb86f95a0ed13870ab2391 /src/runtime/malloc.go
parentc5be4ed7df3b2ae8f9d0a5c85afa4cf49e22a56d (diff)
downloadgo-d29a0282e9b7340ba2ed3f506e66304e92580238.tar.xz
runtime: add mayAcquire annotation for finlock
We're missing lock edges to finlock that happen only rarely. Anything that calls mallocgc can potentially trigger sweeping, which can potentially queue a finalizer, which acquires finlock. While this can happen on any malloc, it happens relatively rarely, so we simply haven't seen some of the lock edges that could happen. Add a mayAcquire annotation to mallocgc to capture the possibility of acquiring finlock. With this change, we add "fin" to the set of "malloc" locks. Several of these edges were already there, but not quite all of them. This was found by inspecting the rank graph for things that didn't make sense. For #53789. Change-Id: Idc10ce6f250596b0c07ba07ac93f2198fb38c22b Reviewed-on: https://go-review.googlesource.com/c/go/+/418717 Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/runtime/malloc.go')
-rw-r--r--src/runtime/malloc.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/runtime/malloc.go b/src/runtime/malloc.go
index 5866a4597b..b044e29d95 100644
--- a/src/runtime/malloc.go
+++ b/src/runtime/malloc.go
@@ -847,6 +847,11 @@ func mallocgc(size uintptr, typ *_type, needzero bool) unsafe.Pointer {
if size == 0 {
return unsafe.Pointer(&zerobase)
}
+
+ // It's possible for any malloc to trigger sweeping, which may in
+ // turn queue finalizers. Record this dynamic lock edge.
+ lockRankMayQueueFinalizer()
+
userSize := size
if asanenabled {
// Refer to ASAN runtime library, the malloc() function allocates extra memory,