fix(form):add max iteration to avoid stack overflow #3701
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
example code:
if param to be parsed contains nested field ,goroutine will crash
runtime: goroutine stack exceeds 1000000000-byte limit
runtime: sp=0xc020460418 stack=[0xc020460000, 0xc040460000]
fatal error: stack overflow
runtime stack:
runtime.throw({0x13bad15?, 0x16315c0?})
/usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0x700007c93da0 sp=0x700007c93d70 pc=0x10345bd
runtime.newstack()
/usr/local/go/src/runtime/stack.go:1104 +0x5cc fp=0x700007c93f58 sp=0x700007c93da0 pc=0x104dcec
runtime.morestack()
/usr/local/go/src/runtime/asm_amd64.s:570 +0x8b fp=0x700007c93f60 sp=0x700007c93f58 pc=0x10636cb
goroutine 7 [running]:
runtime.heapBitsSetType(0xc001c7f350?, 0x18?, 0x18?, 0x1377180?)
/usr/local/go/src/runtime/mbitmap.go:844 +0xbac fp=0xc020460428 sp=0xc020460420 pc=0x101556c
runtime.mallocgc(0x18, 0x1377180, 0x1)
/usr/local/go/src/runtime/malloc.go:1050 +0x64d fp=0xc0204604a0 sp=0xc020460428 pc=0x100cb6d
reflect.unsafe_New(0x7?)
/usr/local/go/src/runtime/malloc.go:1197 +0x27 fp=0xc0204604c8 sp=0xc0204604a0 pc=0x105eba7
reflect.New({0x1465920?, 0x1377180})
/usr/local/go/src/reflect/value.go:3139 +0x5d fp=0xc0204604f8 sp=0xc0204604c8 pc=0x10aaffd
github.com/gin-gonic/gin/binding.mapping({0x1341520?, 0xc001c7f348?, 0xc001c80a20?}, {{0x133308c, 0x5}, {0x0, 0x0}, {0x1465920, 0x1341520}, {0x1333092, ...}, ...}, ...)
/Users/gaochong/GoProjects/gin/binding/form_mapping.go:81 +0x27d fp=0xc0204606e0 sp=0xc0204604f8 pc=0x131429d
github.com/gin-gonic/gin/binding.mapping({0x136d4c0?, 0xc001c7f348?, 0x0?}, {{0x13362f0, 0x7}, {0x0, 0x0}, {0x1465920, 0x136d4c0}, {0x13362f8, ...}, ...}, ...)
/Users/gaochong/GoProjects/gin/binding/form_mapping.go:112 +0x550 fp=0xc0204608c8 sp=0xc0204606e0 pc=0x1314570
github.com/gin-gonic/gin/binding.mapping({0x1377180?, 0xc001c7f338?, 0xc001c80a00?}, {{0x133308c, 0x5}, {0x0, 0x0}, {0x1465920, 0x1341520}, {0x1333092, ...}, ...}, ...)
/Users/gaochong/GoProjects/gin/binding/form_mapping.go:112 +0x550 fp=0xc020460ab0 sp=0xc0204608c8 pc=0x1314570
github.com/gin-gonic/gin/binding.mapping({0x1341520?, 0xc001c7f330?, 0xc001c809f0?}, {{0x133308c, 0x5}, {0x0, 0x0}, {0x1465920, 0x1341520}, {0x1333092, ...}, ...}, ...)
/Users/gaochong/GoProjects/gin/binding/form_mapping.go:83 +0x318 fp=0xc020460c98 sp=0xc020460ab0 pc=0x1314338
github.com/gin-gonic/gin/binding.mapping({0x136d4c0?, 0xc001c7f330?, 0x0?}, {{0x13362f0, 0x7}, {0x0, 0x0}, {0x1465920, 0x136d4c0}, {0x13362f8, ...}, ...}, ...)
/Users/gaochong/GoProjects/gin/binding/form_mapping.go:112 +0x550 fp=0xc020460e80 sp=0xc020460c98 pc=0x1314570
github.com/gin-gonic/gin/binding.mapping({0x1377180?, 0xc001c7f320?, 0xc001c809d0?}, {{0x133308c, 0x5}, {0x0, 0x0}, {0x1465920, 0x1341520}, {0x1333092, ...}, ...}, ...)