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

encoder cache out of range panic #381

Closed
trim21 opened this issue Jul 10, 2022 · 0 comments · Fixed by #382
Closed

encoder cache out of range panic #381

trim21 opened this issue Jul 10, 2022 · 0 comments · Fixed by #382
Labels
bug Something isn't working

Comments

@trim21
Copy link
Contributor

trim21 commented Jul 10, 2022

panic: runtime error: index out of range [17382] with length 17382 [recovered]
        panic: runtime error: index out of range [17382] with length 17382

goroutine 568 [running]:
panic({0xfe03c0, 0xc0006653c8})
        C:/Users/Trim21/.g/go/src/runtime/panic.go:838 +0x207
github.com/goccy/go-json/internal/encoder.CompileToGetCodeSet(0x0?, 0x0?)
        C:/Users/Trim21/proj/golang/goccy-go-json/internal/encoder/compiler_norace.go:15 +0x207
github.com/goccy/go-json.encode(0xc000378410, {0xfffc60, 0xc0007ca0e0})
        C:/Users/Trim21/proj/golang/goccy-go-json/encode.go:226 +0xd0
github.com/goccy/go-json.marshal({0xfffc60, 0xc0007ca0e0}, {0x0, 0x0, 0xc0004adef4?})
        C:/Users/Trim21/proj/golang/goccy-go-json/encode.go:150 +0xba
github.com/goccy/go-json.MarshalWithOption(...)
        C:/Users/Trim21/proj/golang/goccy-go-json/json.go:186
github.com/goccy/go-json.Marshal({0xfffc60?, 0xc0007ca0e0?})
        C:/Users/Trim21/proj/golang/goccy-go-json/json.go:171 +0x2a

re-produce test case: (64 bit os and golang)

func TestIssueLargeStruct(t *testing.T) {
	var v struct {
		Field0  bool
		Field1  bool
		Field2  bool
		Field3  bool
		Field4  bool
		Field5  bool
		Field6  bool
		Field7  bool
		Field8  bool
		Field9  bool
		Field10 bool
		Field11 bool
		Field12 bool
		Field13 bool
		Field14 bool
		Field15 bool
		Field16 bool
		Field17 bool
		Field18 bool
		Field19 bool
		Field20 bool
		Field21 bool
		Field22 bool
		Field23 bool
		Field24 bool
		Field25 bool
		Field26 bool
		Field27 bool
		Field28 bool
		Field29 bool
		Field30 bool
		Field31 bool
		Field32 bool
		Field33 bool
		Field34 bool
		Field35 bool
		Field36 bool
		Field37 bool
		Field38 bool
		Field39 bool
		Field40 bool
		Field41 bool
		Field42 bool
		Field43 bool
		Field44 bool
		Field45 bool
		Field46 bool
		Field47 bool
		Field48 bool
		Field49 bool
		Field50 bool
		Field51 bool
		Field52 bool
		Field53 bool
		Field54 bool
		Field55 bool
		Field56 bool
		Field57 bool
		Field58 bool
		Field59 bool
		Field60 bool
		Field61 bool
		Field62 bool
		Field63 bool
		Field64 bool
		Field65 bool
		Field66 bool
		Field67 bool
		Field68 bool
		Field69 bool
		Field70 bool
		Field71 bool
		Field72 bool
		Field73 bool
		Field74 bool
		Field75 bool
		Field76 bool
		Field77 bool
		Field78 bool
		Field79 bool
		Field80 bool
		Field81 bool
		Field82 bool
		Field83 bool
		Field84 bool
		Field85 bool
		Field86 bool
		Field87 bool
		Field88 bool
		Field89 bool
		Field90 bool
		Field91 bool
		Field92 bool
		Field93 bool
		Field94 bool
		Field95 bool
		Field96 bool
		Field97 bool
		Field98 bool
		Field99 bool
	}

	json.Marshal(v)
}

debug info:

typeptr equal to typeAddr.MaxTypeAddr in this case

if typeptr > typeAddr.MaxTypeAddr || typeptr < typeAddr.BaseTypeAddr {

@goccy goccy added the bug Something isn't working label Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants