Skip to content

Commit

Permalink
pkg/proc: Fix crash when LocationExpr is nil
Browse files Browse the repository at this point in the history
Add nil check for v.LocationExpr and keep unreadable error of var.

Fix go-delve#2049
  • Loading branch information
chainhelen committed Jul 16, 2020
1 parent 8571fdd commit a77da42
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/proc/eval.go
Expand Up @@ -261,13 +261,16 @@ func (scope *EvalScope) Locals() ([]*Variable, error) {
locationExpr := v.LocationExpr
declLine := v.DeclLine
v = v.maybeDereference()
if v.Addr == 0 {
if v.Addr == 0 && v.Unreadable == nil {
v.Unreadable = fmt.Errorf("no address for escaped variable")
}
v.Name = name[1:]
v.Flags |= VariableEscaped
locationExpr.isEscaped = true
v.LocationExpr = locationExpr
// See https://github.com/go-delve/delve/issues/2049 for details
if locationExpr != nil {
locationExpr.isEscaped = true
v.LocationExpr = locationExpr
}
v.DeclLine = declLine
vars[i] = v
}
Expand Down

0 comments on commit a77da42

Please sign in to comment.