From 6269244a98ff1e4e0133d507c483bb75732c5412 Mon Sep 17 00:00:00 2001 From: aarzilli Date: Wed, 3 Jan 2018 11:13:43 +0100 Subject: [PATCH] proc: check error accessing g.m.curg in GetG I saw a test failure related to this in Travis-CI, if it happens again I would like to know what's causing it. --- pkg/proc/threads.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/proc/threads.go b/pkg/proc/threads.go index 9a05f4d4..4950187b 100644 --- a/pkg/proc/threads.go +++ b/pkg/proc/threads.go @@ -354,15 +354,15 @@ func newGVariable(thread Thread, gaddr uintptr, deref bool) (*Variable, error) { // // In order to get around all this craziness, we read the address of the G structure for // the current thread from the thread local storage area. -func GetG(thread Thread) (g *G, err error) { +func GetG(thread Thread) (*G, error) { gaddr, err := getGVariable(thread) if err != nil { return nil, err } - g, err = gaddr.parseG() + g, err := gaddr.parseG() if err != nil { - return + return nil, err } if g.ID == 0 { // The runtime uses a special goroutine with ID == 0 to mark that the @@ -372,10 +372,13 @@ func GetG(thread Thread) (g *G, err error) { // For our purposes it's better if we always return the real goroutine // since the rest of the code assumes the goroutine ID is univocal. // The real 'current goroutine' is stored in g0.m.curg - curgvar, _ := g.variable.fieldVariable("m").structMember("curg") + curgvar, err := g.variable.fieldVariable("m").structMember("curg") + if err != nil { + return nil, err + } g, err = curgvar.parseG() if err != nil { - return + return nil, err } g.SystemStack = true } @@ -383,7 +386,7 @@ func GetG(thread Thread) (g *G, err error) { if loc, err := thread.Location(); err == nil { g.CurrentLoc = *loc } - return + return g, nil } // ThreadScope returns an EvalScope for this thread. -- GitLab