Skip to content

Commit

Permalink
interp.FilterStack: don't sync up with callers only on runCfg
Browse files Browse the repository at this point in the history
interpreter may be entered (for example) from genFunctionWrapper
  • Loading branch information
bailsman committed Jan 2, 2022
1 parent 5262f9a commit a8f4038
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions interp/interp.go
Original file line number Diff line number Diff line change
Expand Up @@ -684,30 +684,30 @@ func (interp *Interpreter) FilterStackAndCallers(stack []byte, callers []uintptr
continue
}

// This is the first call into the interpreter, so try to sync callers
if callersIndex == notSyncedYet {
for j, call := range callers {
if call == 0 {
break
}
callName := runtime.FuncForPC(call).Name()
if callName == strings.Split(p[0], "(")[0] {
callersIndex = j
}
}
for j := len(callers) - 1; j > callersIndex; j-- {
if callers[j] != 0 {
newCallers = append(newCallers, callers[j])
}
}
}

var handle uintptr

// A runCfg call refers to an interpreter level call
// grab callHandle from the first parameter to it
if strings.HasPrefix(funcPath[1], "runCfg(") {
fmt.Sscanf(funcPath[1], "runCfg(%v,", &handle)
// if this is the oldest call to runCfg, sync up with callers array
if callersIndex == notSyncedYet {
for j, call := range callers {
if call == 0 {
break
}

callName := runtime.FuncForPC(call).Name()
if callName == selfPrefix+"/interp.runCfg" {
callersIndex = j
}
}
for j := len(callers) - 1; j > callersIndex; j-- {
if callers[j] != 0 {
newCallers = append(newCallers, callers[j])
}
}
}
}

// callBin is a call to a binPkg
Expand Down

0 comments on commit a8f4038

Please sign in to comment.