From 2a46f55b359909ab0710f7952747811dfae07a50 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Fri, 24 Apr 2015 16:37:31 -0400 Subject: [PATCH] runtime: panic when idling a P with runnable Gs This adds a check that we never put a P on the idle list when it has work on its local run queue. Change-Id: Ifcfab750de60c335148a7f513d4eef17be03b6a7 Reviewed-on: https://go-review.googlesource.com/9324 Reviewed-by: Rick Hudson Reviewed-by: Dmitry Vyukov --- src/runtime/proc1.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/runtime/proc1.go b/src/runtime/proc1.go index a2956fe1ad..350d6bfbdf 100644 --- a/src/runtime/proc1.go +++ b/src/runtime/proc1.go @@ -3180,6 +3180,9 @@ func globrunqget(_p_ *p, max int32) *g { // May run during STW, so write barriers are not allowed. //go:nowritebarrier func pidleput(_p_ *p) { + if !runqempty(_p_) { + throw("pidleput: P has non-empty run queue") + } _p_.link = sched.pidle sched.pidle.set(_p_) xadd(&sched.npidle, 1) // TODO: fast atomic -- 2.48.1