From b851e51160bc8ed412e229152b430b75e7ce56f9 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 11 Mar 2020 21:51:09 -0700 Subject: runtime: don't crash on mlock failure Instead, note that mlock has failed, start trying the mitigation of touching the signal stack before sending a preemption signal, and, if the program crashes, mention the possible problem and a wiki page describing the issue (https://golang.org/wiki/LinuxKernelSignalVectorBug). Tested on a kernel in the buggy version range, but with the patch, by using `ulimit -l 0`. Fixes #37436 Change-Id: I072aadb2101496dffd655e442fa5c367dad46ce8 Reviewed-on: https://go-review.googlesource.com/c/go/+/223121 Run-TryBot: Ian Lance Taylor Reviewed-by: Austin Clements Reviewed-by: Keith Randall --- src/runtime/panic.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/runtime/panic.go') diff --git a/src/runtime/panic.go b/src/runtime/panic.go index c6ab1bac3f..28b5cbefcc 100644 --- a/src/runtime/panic.go +++ b/src/runtime/panic.go @@ -1281,6 +1281,12 @@ func startpanic_m() bool { } } +// throwReportQuirk, if non-nil, is called by throw after dumping the stacks. +// +// TODO(austin): Remove this after Go 1.15 when we remove the +// mlockGsignal workaround. +var throwReportQuirk func() + var didothers bool var deadlock mutex @@ -1327,6 +1333,10 @@ func dopanic_m(gp *g, pc, sp uintptr) bool { printDebugLog() + if throwReportQuirk != nil { + throwReportQuirk() + } + return docrash } -- cgit v1.3-5-g9baa