proc/variables: bugfix: infinite loading loop through maps

Fixes #341
This commit is contained in:
aarzilli 2016-01-10 10:04:14 +01:00
parent 26c0307aef
commit 6d50aba71d
3 changed files with 21 additions and 4 deletions

@ -46,6 +46,8 @@ type dstruct struct {
x interface{} x interface{}
} }
type maptype map[string]interface{}
func main() { func main() {
i1 := 1 i1 := 1
i2 := 2 i2 := 2
@ -134,6 +136,8 @@ func main() {
var iface5 interface{} = &recursive1 var iface5 interface{} = &recursive1
var iface2fn1 interface{} = afunc1 var iface2fn1 interface{} = afunc1
var iface2fn2 interface{} = afunc2 var iface2fn2 interface{} = afunc2
var mapinf maptype = map[string]interface{}{}
mapinf["inf"] = mapinf
var amb1 = 1 var amb1 = 1
runtime.Breakpoint() runtime.Breakpoint()
@ -141,5 +145,5 @@ func main() {
fmt.Println(amb1) fmt.Println(amb1)
} }
runtime.Breakpoint() runtime.Breakpoint()
fmt.Println(i1, i2, i3, p1, amb1, s1, s3, a1, p2, p3, s2, as1, str1, f1, fn1, fn2, nilslice, nilptr, ch1, chnil, m1, mnil, m2, m3, up1, i4, i5, i6, err1, err2, errnil, iface1, iface2, ifacenil, arr1, parr, cpx1, const1, iface3, iface4, recursive1, recursive1.x, iface5, iface2fn1, iface2fn2) fmt.Println(i1, i2, i3, p1, amb1, s1, s3, a1, p2, p3, s2, as1, str1, f1, fn1, fn2, nilslice, nilptr, ch1, chnil, m1, mnil, m2, m3, up1, i4, i5, i6, err1, err2, errnil, iface1, iface2, ifacenil, arr1, parr, cpx1, const1, iface3, iface4, recursive1, recursive1.x, iface5, iface2fn1, iface2fn2, mapinf)
} }

@ -1264,3 +1264,14 @@ func TestIssue262(t *testing.T) {
} }
}) })
} }
func TestIssue341(t *testing.T) {
// pointer loop through map entries
withTestProcess("testvariables3", t, func(p *Process, fixture protest.Fixture) {
assertNoError(p.Continue(), t, "Continue()")
t.Logf("requesting mapinf")
mapinf, err := evalVariable(p, "mapinf")
assertNoError(err, t, "EvalVariable()")
t.Logf("mapinf: %v\n", mapinf)
})
}

@ -1160,8 +1160,10 @@ func (v *Variable) loadMap(recurseLevel int) {
} }
key := it.key() key := it.key()
val := it.value() val := it.value()
key.loadValue() if recurseLevel <= maxVariableRecurse {
val.loadValue() key.loadValueInternal(recurseLevel + 1)
val.loadValueInternal(recurseLevel + 1)
}
if key.Unreadable != nil || val.Unreadable != nil { if key.Unreadable != nil || val.Unreadable != nil {
errcount++ errcount++
} }
@ -1428,7 +1430,7 @@ func (v *Variable) loadInterface(recurseLevel int, loadData bool) {
// interface to nil // interface to nil
data = data.maybeDereference() data = data.maybeDereference()
v.Children = []Variable{*data} v.Children = []Variable{*data}
v.Children[0].loadValue() v.Children[0].loadValueInternal(recurseLevel)
return return
} }