8000 GC crashes with a fatal error · Issue #2 · yunabe/lgo · GitHub
[go: up one dir, main page]

Skip to content
GC crashes with a fatal error #2
@yunabe

Description

@yunabe

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0