mirror of
https://github.com/go-delve/delve.git
synced 2025-10-30 02:07:58 +08:00
proc: do not try to load a non-empty slice if the base address is 0 (#3295)
This commit is contained in:
committed by
GitHub
parent
372552bf1f
commit
212c2002bb
@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"go/constant"
|
"go/constant"
|
||||||
"math"
|
"math"
|
||||||
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
@ -371,6 +372,10 @@ func main() {
|
|||||||
namedA1 := astructName1{12, 45}
|
namedA1 := astructName1{12, 45}
|
||||||
namedA2 := astructName2{13, 46}
|
namedA2 := astructName2{13, 46}
|
||||||
|
|
||||||
|
badslice := []int{1, 2, 3}
|
||||||
|
h := (*reflect.SliceHeader)(unsafe.Pointer(&badslice))
|
||||||
|
h.Data = 0
|
||||||
|
|
||||||
var amb1 = 1
|
var amb1 = 1
|
||||||
runtime.Breakpoint()
|
runtime.Breakpoint()
|
||||||
for amb1 := 0; amb1 < 10; amb1++ {
|
for amb1 := 0; amb1 < 10; amb1++ {
|
||||||
@ -381,5 +386,5 @@ func main() {
|
|||||||
longslice := make([]int, 100, 100)
|
longslice := make([]int, 100, 100)
|
||||||
|
|
||||||
runtime.Breakpoint()
|
runtime.Breakpoint()
|
||||||
fmt.Println(i1, i2, i3, p1, pp1, amb1, s1, s3, a0, a1, p2, p3, s2, as1, str1, f1, fn1, fn2, nilslice, nilptr, ch1, chnil, m1, mnil, m2, m3, m4, m5, upnil, up1, i4, i5, i6, err1, err2, errnil, iface1, iface2, ifacenil, arr1, parr, cpx1, const1, iface3, iface4, recursive1, recursive1.x, iface5, iface2fn1, iface2fn2, bencharr, benchparr, mapinf, mainMenu, b, b2, sd, anonstruct1, anonstruct2, anoniface1, anonfunc, mapanonstruct1, ifacearr, efacearr, ni8, ni16, ni32, ni64, pinf, ninf, nan, zsvmap, zsslice, zsvar, tm, rettm, errtypednil, emptyslice, emptymap, byteslice, bytestypeslice, runeslice, bytearray, bytetypearray, runearray, longstr, nilstruct, as2, as2.NonPointerRecieverMethod, s4, iface2map, issue1578, ll, unread, w2, w3, w4, w5, longarr, longslice, val, m6, m7, cl, tim1, tim2, typedstringvar, namedA1, namedA2, astructName1(namedA2))
|
fmt.Println(i1, i2, i3, p1, pp1, amb1, s1, s3, a0, a1, p2, p3, s2, as1, str1, f1, fn1, fn2, nilslice, nilptr, ch1, chnil, m1, mnil, m2, m3, m4, m5, upnil, up1, i4, i5, i6, err1, err2, errnil, iface1, iface2, ifacenil, arr1, parr, cpx1, const1, iface3, iface4, recursive1, recursive1.x, iface5, iface2fn1, iface2fn2, bencharr, benchparr, mapinf, mainMenu, b, b2, sd, anonstruct1, anonstruct2, anoniface1, anonfunc, mapanonstruct1, ifacearr, efacearr, ni8, ni16, ni32, ni64, pinf, ninf, nan, zsvmap, zsslice, zsvar, tm, rettm, errtypednil, emptyslice, emptymap, byteslice, bytestypeslice, runeslice, bytearray, bytetypearray, runearray, longstr, nilstruct, as2, as2.NonPointerRecieverMethod, s4, iface2map, issue1578, ll, unread, w2, w3, w4, w5, longarr, longslice, val, m6, m7, cl, tim1, tim2, typedstringvar, namedA1, namedA2, astructName1(namedA2), badslice)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1656,6 +1656,10 @@ func (v *Variable) loadArrayValues(recurseLevel int, cfg LoadConfig) {
|
|||||||
v.Unreadable = errors.New("Negative array length")
|
v.Unreadable = errors.New("Negative array length")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if v.Base == 0 && v.Len > 0 {
|
||||||
|
v.Unreadable = errors.New("non-zero length array with nil base")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
count := v.Len
|
count := v.Len
|
||||||
// Cap number of elements
|
// Cap number of elements
|
||||||
|
|||||||
@ -829,6 +829,9 @@ func TestEvalExpression(t *testing.T) {
|
|||||||
|
|
||||||
// Conversions to ptr-to-ptr types
|
// Conversions to ptr-to-ptr types
|
||||||
{`**(**runtime.hmap)(uintptr(&m1))`, false, `…`, `…`, "runtime.hmap", nil},
|
{`**(**runtime.hmap)(uintptr(&m1))`, false, `…`, `…`, "runtime.hmap", nil},
|
||||||
|
|
||||||
|
// Malformed values
|
||||||
|
{`badslice`, false, `(unreadable non-zero length array with nil base)`, `(unreadable non-zero length array with nil base)`, "[]int", nil},
|
||||||
}
|
}
|
||||||
|
|
||||||
ver, _ := goversion.Parse(runtime.Version())
|
ver, _ := goversion.Parse(runtime.Version())
|
||||||
|
|||||||
Reference in New Issue
Block a user