diff --git a/_fixtures/testvariables2.go b/_fixtures/testvariables2.go index 26439c9d..ce9a7c19 100644 --- a/_fixtures/testvariables2.go +++ b/_fixtures/testvariables2.go @@ -5,6 +5,7 @@ import ( "go/constant" "math" "reflect" + "os" "runtime" "time" "unsafe" @@ -365,6 +366,7 @@ func main() { w5 := &W5{nil} w5.W5 = w5 + os.Setenv("TZ", "UTC") tim1 := time.Unix(233431200, 0) loc, _ := time.LoadLocation("Mexico/BajaSur") tim2, _ := time.ParseInLocation("2006-01-02 15:04:05", "2022-06-07 02:03:04", loc) @@ -375,6 +377,7 @@ func main() { badslice := []int{1, 2, 3} h := (*reflect.SliceHeader)(unsafe.Pointer(&badslice)) h.Data = 0 + tim3 := time.Date(300000, 1, 1, 0, 0, 0, 0, time.Local) var amb1 = 1 runtime.Breakpoint() @@ -386,5 +389,5 @@ func main() { longslice := make([]int, 100, 100) 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), badslice) + 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, tim3) } diff --git a/pkg/proc/variables.go b/pkg/proc/variables.go index b1dc27e5..a41dac86 100644 --- a/pkg/proc/variables.go +++ b/pkg/proc/variables.go @@ -2595,6 +2595,10 @@ func (v *Variable) formatTime() { } else { // the full signed 64-bit wall seconds since Jan 1 year 1 is stored in ext var t time.Time + if ext > int64(maxAddSeconds/time.Second)*1000 { + // avoid doing the add loop below if it will take too much time + return + } for ext > int64(maxAddSeconds/time.Second) { t = t.Add(maxAddSeconds) ext -= int64(maxAddSeconds / time.Second) diff --git a/pkg/proc/variables_test.go b/pkg/proc/variables_test.go index dab345b4..2b7095a9 100644 --- a/pkg/proc/variables_test.go +++ b/pkg/proc/variables_test.go @@ -795,6 +795,7 @@ func TestEvalExpression(t *testing.T) { // pretty printing special types {"tim1", false, `time.Time(1977-05-25T18:00:00Z)…`, `time.Time(1977-05-25T18:00:00Z)…`, "time.Time", nil}, {"tim2", false, `time.Time(2022-06-07T02:03:04-06:00)…`, `time.Time(2022-06-07T02:03:04-06:00)…`, "time.Time", nil}, + {"tim3", false, `time.Time {…`, `time.Time {…`, "time.Time", nil}, // issue #3034 - map access with long string key {`m6["very long string 0123456789a0123456789b0123456789c0123456789d0123456789e0123456789f0123456789g012345678h90123456789i0123456789j0123456789"]`, false, `123`, `123`, "int", nil},