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

encoding non-record types results in panic #45

Open
rogpeppe opened this issue Jan 27, 2020 · 0 comments
Open

encoding non-record types results in panic #45

rogpeppe opened this issue Jan 27, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@rogpeppe
Copy link
Contributor

This code panics because the newAzTypeInfo code doesn't recognize that a non-record type might have entries.

	type R struct {
		A int
	}
	avro.Marshal(&R{13})
panic: runtime error: index out of range [0] with length 0 [recovered]
	panic: runtime error: index out of range [0] with length 0

goroutine 42 [running]:
testing.tRunner.func1.1(0x648c80, 0xc0000a0820)
	/home/rog/go/src/testing/testing.go:942 +0x3d0
testing.tRunner.func1(0xc0002018c0)
	/home/rog/go/src/testing/testing.go:945 +0x3f9
panic(0x648c80, 0xc0000a0820)
	/home/rog/go/src/runtime/panic.go:967 +0x15d
github.com/heetch/avro.typeEncoderUncached(0xc000056300, 0x6b5b20, 0xc00020dac0, 0x6b6a40, 0x5fefa0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/rog/src/heetch/avro/encode.go:181 +0x1725
github.com/heetch/avro.typeEncoder0(0xc000056300, 0x0, 0x0, 0x6b6a40, 0x5fefa0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/rog/src/heetch/avro/encode.go:121 +0x146
github.com/heetch/avro.marshalAppend(0xc000056300, 0x0, 0x0, 0x0, 0x5fefa0, 0xc0000f6b48, 0x16, 0x0, 0x0, 0x0, ...)
	/home/rog/src/heetch/avro/encode.go:41 +0xde
github.com/heetch/avro.Marshal(0x5fefa0, 0xc0000f6b48, 0x453d99, 0x72902ea491ca, 0x2c540c30, 0x2c540c300000000f, 0x5e2ecb98, 0xc000036770)
	/home/rog/src/heetch/avro/encode.go:31 +0xc5
github.com/heetch/avro_test.TestGoTypeEncodeWithPointer(0xc0002018c0)
	/home/rog/src/heetch/avro/gotype_test.go:273 +0x8c
testing.tRunner(0xc0002018c0, 0x670460)
	/home/rog/go/src/testing/testing.go:993 +0xdc
created by testing.(*T).Run
	/home/rog/go/src/testing/testing.go:1044 +0x357

goroutine 1 [chan receive]:
testing.(*T).Run(0xc0002018c0, 0x666eaa, 0x1b, 0x670460, 0x483e01)
	/home/rog/go/src/testing/testing.go:1045 +0x37e
testing.runTests.func1(0xc000158000)
	/home/rog/go/src/testing/testing.go:1286 +0x78
testing.tRunner(0xc000158000, 0xc000047e10)
	/home/rog/go/src/testing/testing.go:993 +0xdc
testing.runTests(0xc00000c220, 0x82c7a0, 0x13, 0x13, 0x0)
	/home/rog/go/src/testing/testing.go:1284 +0x2a7
testing.(*M).Run(0xc000156000, 0x0)
	/home/rog/go/src/testing/testing.go:1201 +0x15f
main.main()
	_testmain.go:86 +0x135
go: exit 1
exit status 2
FAIL	github.com/heetch/avro	0.012s
@rogpeppe rogpeppe added the bug Something isn't working label Jan 27, 2020
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

No branches or pull requests

1 participant