FastBinaryEncoding icon indicating copy to clipboard operation
FastBinaryEncoding copied to clipboard

Go Serialization panics on nested struct field.

Open sadiq1971 opened this issue 1 year ago • 2 comments

It seems the serialization is panicking in the case of a struct containing a nested field. Not sure whether this feature is supported or not, or is there anything that needs to be done on the .fbe file as nothing is mentioned on the docs fbe file definition:

package proto

struct NestedTest
{
   NestedTest? nested;
}

The command used for building go source files: fbec --input=nested.fbe --output=. --go --final --proto --json

Go code for serialization:

        cnt := filespb.NewNestedTest()
	writer := filespb.NewNestedTestFinalModel(fbe.NewEmptyBuffer())
	if _, err := writer.Serialize(cnt); err != nil {
		panic("serialization error")
	}
	if ok := writer.Verify(); !ok {
		panic("verify error")
	}

panic trace:

runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc023180418 stack=[0xc023180000, 0xc043180000]
fatal error: stack overflow

runtime stack:
runtime.throw({0xe0939b?, 0x14ccaa0?})
	/home/sadiq/go/go1.19.1/src/runtime/panic.go:1047 +0x5d fp=0x7f8ca1ffacb8 sp=0x7f8ca1ffac88 pc=0x43b57d

sadiq1971 avatar Feb 28 '23 22:02 sadiq1971