]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: setg after sigFetchG
authorCherry Zhang <cherryyz@google.com>
Thu, 31 Oct 2019 03:14:34 +0000 (23:14 -0400)
committerCherry Zhang <cherryyz@google.com>
Tue, 5 Nov 2019 18:58:29 +0000 (18:58 +0000)
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 <iant@golang.org>
src/runtime/signal_unix.go

index 5e4361e7a1bb023300a67dec4455c99c0e138303..6563186392ce4c96e7539dd0cddc2dbdc93ba85d 100644 (file)
@@ -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())