chronoxor / FastBinaryEncoding

Fast Binary Encoding is ultra fast and universal serialization solution for C++, C#, Go, Java, JavaScript, Kotlin, Python, Ruby, Swift
https://chronoxor.github.io/FastBinaryEncoding
MIT License
876 stars 90 forks source link

Go Serialization panics on nested struct field. #87

Open sadiq1971 opened 1 year ago

sadiq1971 commented 1 year ago

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 commented 1 year ago

@chronoxor

L-LingRen commented 1 year ago

Same the problem, any resolution?