From 070cc8eb02248698480957dd7cd6ada07de309de Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sun, 22 Oct 2017 18:10:08 -0400 Subject: [PATCH] runtime: allow write barriers in startpanic_m We're about to start tracking nowritebarrierrec through systemstack calls, which will reveal write barriers in startpanic_m prohibited by various callers. We actually can allow write barriers here because the write barrier is a no-op when we're panicking. Let the compiler know. Updates #22384. For #22460. Change-Id: Ifb3a38d3dd9a4125c278c3680f8648f987a5b0b8 Reviewed-on: https://go-review.googlesource.com/72770 Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot Reviewed-by: Rick Hudson --- src/runtime/mbarrier.go | 2 ++ src/runtime/panic.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/runtime/mbarrier.go b/src/runtime/mbarrier.go index acc4d14e80..fbead6d378 100644 --- a/src/runtime/mbarrier.go +++ b/src/runtime/mbarrier.go @@ -182,6 +182,8 @@ func gcmarkwb_m(slot *uintptr, ptr uintptr) { func writebarrierptr_prewrite1(dst *uintptr, src uintptr) { mp := acquirem() if mp.inwb || mp.dying > 0 { + // We explicitly allow write barriers in startpanic_m, + // since we're going down anyway. Ignore them here. releasem(mp) return } diff --git a/src/runtime/panic.go b/src/runtime/panic.go index 90a1c0bdd1..11cb05e976 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -654,6 +654,12 @@ func recovery(gp *g) { gogo(&gp.sched) } +// startpanic_m implements unrecoverable panic. +// +// It can have write barriers because the write barrier explicitly +// ignores writes once dying > 0. +// +//go:yeswritebarrierrec func startpanic_m() { _g_ := getg() if mheap_.cachealloc.size == 0 { // very early -- 2.48.1