faker icon indicating copy to clipboard operation
faker copied to clipboard

[BUG] Struct().Fill() is not correctly handling nested structures

Open bigfoot31 opened this issue 2 years ago • 4 comments

Describe the bug goroutine stack exceeds 1000000000-byte limit

To Reproduce

type A struct {
children []*A
}
tmp := A{}
f.Struct().Fill(&tmp)

Expected behavior A clear and concise description of what you expected to happen.

Screenshots image

Desktop (please complete the following information):

  • OS: macOS 12.2.1
  • go version output: go version go1.17.3 darwin/amd64

bigfoot31 avatar Mar 15 '22 19:03 bigfoot31

@bigfoot31 this issue is quite old now and we have tests to validate nested structures, would you mind check if this error happens with the newest version? If still happens, can you provide a complete code sample you are using?

jaswdr avatar Dec 25 '22 13:12 jaswdr

It sill happens on the last tagged version and the master branch

package main

import (
	"github.com/jaswdr/faker"
)

type A struct {
	ChildrenType1 []*A
}

func main() {
	tmp := A{}
	faker.New().Struct().Fill(&tmp)
}

runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc020260408 stack=[0xc020260000, 0xc040260000]
fatal error: stack overflow

gboddin avatar Mar 15 '23 14:03 gboddin

Tips : if you don't care about the field :

type A struct {
	ChildrenType1 []*A `fake:"skip"`
}

gboddin avatar Mar 15 '23 14:03 gboddin

I'm taking a look on this

jaswdr avatar Mar 22 '23 17:03 jaswdr