misusage of runtime.sysAlloc may lead to runtime failure in Go 1.19
To Reproduce
run this test in go1.19
func TestSysAlloc(t *testing.T) {
convey.Convey("sysAlloc", t, func() {
convey.So(func() {
data := AllocatePage()
// try write first and last byte of data
data[0] = 0
data[len(data)-1] = 0
// try get mem stat
m := runtime.MemStats{}
runtime.ReadMemStats(&m)
ReleasePage(data)
}, convey.ShouldNotPanic)
})
}
Expected behavior
should not panic
Screenshots
Mockey version:
v1.1.0
Environment:
go1.19
Additional context
In page.go, mockey pass a virtual memStats to runtime.sysAlloc, which looks ok before go1.19:
Describe the bug
misusage of runtime.sysAlloc may lead to runtime failure in Go 1.19
To Reproduce
run this test in go1.19
Expected behavior
should not panic
Screenshots![image](https://user-images.githubusercontent.com/13182823/212856401-3be88205-81b7-47d0-8cbc-463ae011b156.png)
Mockey version: v1.1.0
Environment: go1.19
Additional context In
page.go
, mockey pass a virtual memStats to runtime.sysAlloc, which looks ok before go1.19:Go 1.19 add some statistics in
runtime.sysAlloc
, as below:When reading memory allocator statistics, which calls
runtime.readmemstats_m
, it will lead to a crash: