From a77da42096e95eb0f09e68349a5ae12ee7fa4425 Mon Sep 17 00:00:00 2001 From: chainhelen Date: Wed, 8 Jul 2020 12:06:18 +0800 Subject: [PATCH] pkg/proc: Fix crash when LocationExpr is nil Add nil check for v.LocationExpr and keep unreadable error of var. Fix #2049 --- pkg/proc/eval.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/proc/eval.go b/pkg/proc/eval.go index f43ee5b283..ddcb7001ff 100644 --- a/pkg/proc/eval.go +++ b/pkg/proc/eval.go @@ -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 }