-
Notifications
You must be signed in to change notification settings - Fork 123
Closed
Description
The following code crashes with a fatal error: found bad pointer in Go heap (incorrect use of unsafe or cgo?) message
import (
"fmt"
"log"
"runtime"
)
type MyData struct {
b []byte
}
func (m *MyData) Size() int {
return len(m.b)
}
func NewMyData() *MyData {
return &MyData{
b: make([]byte, 10 * (1 << 20)),
}
}
var l []*MyData
for i := 0; i < 100; i++ {
d := NewMyData()
l = append(l, d)
}
l = nil
runtime.GC()
Metadata
Metadata
Assignees
Labels
No labels