aboutsummaryrefslogtreecommitdiff
path: root/src/sync/pool.go
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2023-07-29 08:59:20 -0700
committerGopher Robot <gobot@golang.org>2023-07-31 22:18:47 +0000
commitbe0e0b06ac53d3d02ea83b479790404057b6f19b (patch)
treed90f3fbad490290bb46623717b239adabea796ad /src/sync/pool.go
parenta2905e95a04858c8702a29c96b891344d3652e41 (diff)
downloadgo-be0e0b06ac53d3d02ea83b479790404057b6f19b.tar.xz
sync: panic rather than throw on nil *Pool
Fixes #61651 Change-Id: I27d581719e6bf38910f9d47dcf023bbff74ddf72 Reviewed-on: https://go-review.googlesource.com/c/go/+/514037 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com>
Diffstat (limited to 'src/sync/pool.go')
-rw-r--r--src/sync/pool.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/sync/pool.go b/src/sync/pool.go
index cf01e2e189..ffab67bf19 100644
--- a/src/sync/pool.go
+++ b/src/sync/pool.go
@@ -196,6 +196,13 @@ func (p *Pool) getSlow(pid int) any {
// returns poolLocal pool for the P and the P's id.
// Caller must call runtime_procUnpin() when done with the pool.
func (p *Pool) pin() (*poolLocal, int) {
+ // Check whether p is nil to get a panic.
+ // Otherwise the nil dereference happens while the m is pinned,
+ // causing a fatal error rather than a panic.
+ if p == nil {
+ panic("nil Pool")
+ }
+
pid := runtime_procPin()
// In pinSlow we store to local and then to localSize, here we load in opposite order.
// Since we've disabled preemption, GC cannot happen in between.