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

Infinite recursion with custom type mapping #23

Closed
vearutop opened this issue Sep 12, 2017 · 0 comments
Closed

Infinite recursion with custom type mapping #23

vearutop opened this issue Sep 12, 2017 · 0 comments

Comments

@vearutop
Copy link
Contributor

If type mapped structure is nested in another structure, infinite recursion happens with

runtime: goroutine stack exceeds 1000000000-byte limit
fatal error: stack overflow

runtime stack:
runtime.throw(0x137c04d, 0xe)
        /usr/local/Cellar/go/1.9/libexec/src/runtime/panic.go:605 +0x95
runtime.newstack(0x0)
        /usr/local/Cellar/go/1.9/libexec/src/runtime/stack.go:1050 +0x73b
runtime.morestack()
        /usr/local/Cellar/go/1.9/libexec/src/runtime/asm_amd64.s:415 +0x86

goroutine 9 [running]:
github.com/lazada/swgen.(*Generator).ParseDefinition(0xc4601ff000, 0x1308de0, 0x13b74a0, 0xc4200a6ce8, 0x1, 0x0, 0x0, 0x0, 0x0, 0x1379c89, ...)
        /Users/vpoturaev/golang/src/github.com/lazada/swgen/parser.go:108 +0x1d13 fp=0xc440201338 sp=0xc440201330 pc=0x12b88b3
github.com/lazada/swgen.(*Generator).ParseDefinition(0xc4601ff000, 0x1334780, 0xc4200e88c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /Users/vpoturaev/golang/src/github.com/lazada/swgen/parser.go:138 +0x1c45 fp=0xc440202c38 sp=0xc440201338 pc=0x12b87e5
github.com/lazada/swgen.(*Generator).parseDefInQueue(0xc4601ff000)
        /Users/vpoturaev/golang/src/github.com/lazada/swgen/parser.go:350 +0xf8 fp=0xc440202d78 sp=0xc440202c38 pc=0x12ba358
github.com/lazada/swgen.(*Generator).ParseDefinition(0xc4601ff000, 0x131f060, 0xc42007d320, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1379c89, ...)
        /Users/vpoturaev/golang/src/github.com/lazada/swgen/parser.go:206 +0xd02 fp=0xc440204678 sp=0xc440202d78 pc=0x12b78a2
github.com/lazada/swgen.(*Generator).ParseDefinition(0xc4601ff000, 0x1350700, 0xc42001be30, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /Users/vpoturaev/golang/src/github.com/lazada/swgen/parser.go:138 +0x1c45 fp=0xc440205f78 sp=0xc440204678 pc=0x12b87e5

Sample:

type typeMapHolder struct {
	M typeMap `json:"m"`
}

type typeMap struct {
	R1 int `json:"1"`
	R2 int `json:"2"`
	R3 int `json:"3"`
	R4 int `json:"4"`
	R5 int `json:"5"`
}
gen.AddTypeMap(typeMap{}, map[string]int{})
@ngdinhtoan ngdinhtoan added the bug label Sep 12, 2017
ngdinhtoan added a commit that referenced this issue Sep 12, 2017
Fixes #23 Infinite recursion with custom type mapping
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants