-
Notifications
You must be signed in to change notification settings - Fork 8k
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
[BUG] runtime error: slice bounds out of range [:2] with capacity 1 #2878
Comments
Is it resolved? |
I too am having the same issue, in my case with As an update, interestingly, reverting back to gin 1.7.2 resolves the issue both on Go 1.16 and Go 1.17 This only happens in macOS machines, as far as I can see since the bug is not present in my FreeBSD and Ubuntu servers. |
I am also seeing this issue when upgrading from gin 1.7.2 to 1.7.4 (it is also present in 1.7.3). Unlike @averageflow I am not seeing any differences in operating systems. Definitely seeing it on multiple operating systems. Ubuntu, MacOS, and centos (in a docker container) all have the same issue. Similar to the original post, I can trigger it with the following package main
import (
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
r.GET("/A/:paramOne/B", func(c *gin.Context) { c.String(200, "OK") })
r.GET("/A/:paramOne/C", func(c *gin.Context) { c.String(200, "OK") })
r.Run()
} curl -Ss -X GET http://127.0.0.1:8080/A/mockParam/NOPE
That's as small as I've been able to get it. You seem to need to have two or more routes with partial shared paths that include at least one param. Did a little digging while trying to figure this all out. I don't fully understand the routing code, but seems to be because the big loop in tree.go is running infinitely and will eventually overcome the capacity of the params slice it is expanding and throw this panic. There was a case which I could reproduce in my actual code (which I'm not allowed to share) which caused the loop to run infinitely and not fill anything in the params slice. It just kept looping with no sign of stopping. I let it run for like a minute or something. But I cannot seem to get that to happen with this minimal example I've posted. |
See solution #2897 already merged in the master branch. |
Description
How to reproduce
Expectations
Actual result
Gin traceback:
Environment
The text was updated successfully, but these errors were encountered: