runtime: in getTraceback, set gp->m before gogo
authorIan Lance Taylor <ian@gcc.gnu.org>
Mon, 7 Jan 2019 20:12:39 +0000 (20:12 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 7 Jan 2019 20:12:39 +0000 (20:12 +0000)
commit575eb8f58b06657c9cadfe6f7ddfd9e530fe5dea
treece0dcd8fecef8174761dfaa26962f241b47d9606
parent419af57c134f3b068530ea51179c220e52623067
runtime: in getTraceback, set gp->m before gogo

    Currently, when collecting a traceback for another goroutine,
    getTraceback calls gogo(gp) switching to gp, which will resume in
    mcall, which will call gtraceback, which will set up gp->m. There
    is a gap between setting the current running g to gp and setting
    gp->m. If a profiling signal arrives in between, sigtramp will
    see a non-nil gp with a nil m, and will seg fault. Fix this by
    setting up gp->m first.

    Fixes golang/go#29448.

    Reviewed-on: https://go-review.googlesource.com/c/156038

From-SVN: r267658
gcc/go/gofrontend/MERGE
libgo/go/runtime/pprof/pprof_test.go
libgo/runtime/proc.c