From fb05264fe1626c9d0b6d00d51e6c4d8d213d6dc7 Mon Sep 17 00:00:00 2001 From: Cherry Zhang Date: Wed, 30 Oct 2019 23:14:34 -0400 Subject: [PATCH] runtime: setg after sigFetchG In the normal case, sigFetchG just returns the G register. But in the case that sigFetchG fetches the G from somewhere else, the G register still holding an invalid value. Setg here to make sure they match. This is particularly useful because setGsignalStack, called by adjustSignalStack from sigtrampgo before setg to gsignal, accesses the G register. Should fix #35249. Change-Id: I64c85143cb05cdb2ecca7f9936dbd8bfec186c2d Reviewed-on: https://go-review.googlesource.com/c/go/+/204441 Reviewed-by: Ian Lance Taylor --- src/runtime/signal_unix.go | 1 + 1 file changed, 1 insertion(+) diff --git a/src/runtime/signal_unix.go b/src/runtime/signal_unix.go index 5e4361e7a1..6563186392 100644 --- a/src/runtime/signal_unix.go +++ b/src/runtime/signal_unix.go @@ -394,6 +394,7 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) { } c := &sigctxt{info, ctx} g := sigFetchG(c) + setg(g) if g == nil { if sig == _SIGPROF { sigprofNonGoPC(c.sigpc()) -- 2.50.0