go-delve / delve

Delve is a debugger for the Go programming language.
MIT License
22.37k stars 2.13k forks source link

panic when data length is greater than memCache size #3760

Closed jayantxie closed 3 days ago

jayantxie commented 1 week ago
  1. What version of Delve are you using (dlv version)? v1.22.1
  2. What version of Go are you using? (go version)? go1.22
  3. What operating system and processor architecture are you using? linux/amd64
  4. What did you do? Use *memCache.ReadMemory() to read data with 33554432 length, and then get the error:
panic: runtime error: slice bounds out of range [140022440016544:92856]

goroutine 1 [running]:
github.com/go-delve/delve/pkg/proc.(*memCache).ReadMemory(0xc00045e700, {0xc002b80000, 0x2000000, 0x2000000}, 0x7f59841ab000)
        /Users/bytedance/go/pkg/mod/github.com/go-delve/delve@v1.22.2-0.20240625150328-a4196f35a95c/pkg/proc/mem.go:50 +0x395
github.com/cloudwego/goref/pkg/proc.(*memCache).ReadMemory(0xc0007064c0, {0xc0002ef188, 0x8, 0x8}, 0x7f59841ab000)
        /Users/bytedance/go/src/pkg/proc/mem.go:38 +0x10e
github.com/cloudwego/goref/pkg/proc.readUintRaw({0x1860cc0, 0xc0007064c0}, 0x7f59841ab000, 0x8)
        /Users/bytedance/go/src/pkg/proc/variables.go:454 +0xdd

Code line: https://github.com/go-delve/delve/blob/master/pkg/proc/mem.go#L38

It will overflow when m.cache < size.