FAQ

fatal error: stack overflow

If you are getting the following error:

runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow

It is likely that you have code like:

type Item struct{}

func (i *Item) MarshalMsgpack() ([]byte, error) {
    // This call causes infinite recursion.
    return msgpack.Marshal(i)
}

func (i *Item) UnmarshalMsgpack(b []byte) error {
    // This call causes infinite recursion.
    return msgpack.Unmarshal(b, i)
}

Which can be fixed with:

type Item struct{}

// The new type does not have any methods.
type rawItem Item

func (i *Item) MarshalMsgpack() ([]byte, error) {
    return msgpack.Marshal((*rawItem)(i))
}

func (i *Item) UnmarshalMsgpack(b []byte) error {
    return msgpack.Unmarshal(b, (*rawItem)(i))
}
Last Updated: