From 7ee3f1427b079bb363689321b0565ba7b03de03e Mon Sep 17 00:00:00 2001 From: Michael Anthony Knyszek Date: Fri, 5 Nov 2021 23:35:58 +0000 Subject: runtime: disable GC during debug call tests Currently the debug call protocol implementation we use for testing is riddled with write barriers, and called from a signal handler. This is not safe, as write barriers need a P to execute. Ideally this implementation would be rewritten to avoid the write barriers, but it's not straightforward, and needs some thought. As a temporary measure, disable GC during the debug call tests to avoid a write barrier. Note that this does not indicate a problem with real use of the debug call protocol. Only our test implementation has this issue, because it needs to get executed in a signal handler, normally a separate process is interfacing with the protocol via process signals and ptrace (and the like). Fixes #49370. Change-Id: Ic0fde5d0f4c64f9ecc9789b7dabb3954538fe0a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/361896 Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot Reviewed-by: Michael Pratt --- src/runtime/export_debug_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/runtime/export_debug_test.go') diff --git a/src/runtime/export_debug_test.go b/src/runtime/export_debug_test.go index 032a9b9725..fffc99d7e5 100644 --- a/src/runtime/export_debug_test.go +++ b/src/runtime/export_debug_test.go @@ -107,6 +107,10 @@ type debugCallHandler struct { } func (h *debugCallHandler) inject(info *siginfo, ctxt *sigctxt, gp2 *g) bool { + // TODO(49370): This code is riddled with write barriers, but called from + // a signal handler. Add the go:nowritebarrierrec annotation and restructure + // this to avoid write barriers. + switch h.gp.atomicstatus { case _Grunning: if getg().m != h.mp { @@ -141,7 +145,11 @@ func (h *debugCallHandler) inject(info *siginfo, ctxt *sigctxt, gp2 *g) bool { } func (h *debugCallHandler) handle(info *siginfo, ctxt *sigctxt, gp2 *g) bool { - // Sanity check. + // TODO(49370): This code is riddled with write barriers, but called from + // a signal handler. Add the go:nowritebarrierrec annotation and restructure + // this to avoid write barriers. + + // Double-check m. if getg().m != h.mp { println("trap on wrong M", getg().m, h.mp) return false -- cgit v1.3