Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic: GoString has nil pointer while its length is not zero #495

Open
whatsmonster opened this issue Aug 4, 2023 · 1 comment
Open
Labels
known-issue This issue is known to us, we are working on it

Comments

@whatsmonster
Copy link

whatsmonster commented Aug 4, 2023

panic: val: &rt.GoString{Ptr:(unsafe.Pointer)(nil), Len:28} has nil pointer while its length is not zero!

goroutine 10928255 [running]:
github.com/bytedance/sonic/encoder.goPanic(0x1, 0xc003002810)
/pkg/mod/github.com/bytedance/sonic@v1.8.8/encoder/errors.go:61 +0xb7
github.com/bytedance/sonic/encoder.encodeTypedPointer(0xc0010c8498, 0x21b9760, 0xc000635950, 0xc0095d4000, 0x0, 0x0, 0xc93)
/pkg/mod/github.com/bytedance/sonic@v1.8.8/encoder/primitives.go:77 +0x16c
github.com/bytedance/sonic/encoder.encodeTypedPointer(0xc0010c8498, 0x2156020, 0xc004a685c8, 0xc0095d4000, 0x0, 0xc0010c8498, 0x18)
/pkg/mod/github.com/bytedance/sonic@v1.8.8/encoder/primitives.go:83 +0x1f5
github.com/bytedance/sonic/encoder.encodeInto(0xc0010c8498, 0x2156020, 0xc001124480, 0x0, 0x1, 0x18)
/pkg/mod/github.com/bytedance/sonic@v1.8.8/encoder/encoder.go:211 +0xdf
github.com/bytedance/sonic/encoder.EncodeInto(0xc0010c8498, 0x2156020, 0xc001124480, 0x0, 0x7fd081b405b8, 0x40)
/pkg/mod/github.com/bytedance/sonic@v1.8.8/encoder/encoder.go:200 +0x4d
github.com/bytedance/sonic/encoder.(*StreamEncoder).Encode(0xc008a55a20, 0x2156020, 0xc001124480, 0x2715eb4, 0x1d)
/pkg/mod/github.com/bytedance/sonic@v1.8.8/encoder/stream.go:42 +0xdd
log.(*jsonFormatter).Format(0x414d638, 0xc006a4a190, 0xc005acab08, 0x2, 0x2, 0xc006938120, 0x21)

type Data struct {
	Msg   string    `json:"msg"`
        ....
}

if err := encoder.NewStreamEncoder(buf).Encode(&struct {
		*Data
		Extra      int    `json:"extra"`
	}{
		Data:   data,
		Extra:  extra,
	}); err != nil {
		return nil, err
	}

return buf.Bytes(), nil
@liuq19
Copy link
Collaborator

liuq19 commented Aug 4, 2023

maybe have a concurrency problem, you could use -race to check it

@AsterDY AsterDY added the known-issue This issue is known to us, we are working on it label Aug 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
known-issue This issue is known to us, we are working on it
Projects
None yet
Development

No branches or pull requests

3 participants