Summary
getValue grows the backtrack stack with a raw reslice (*skippedNodes)[:index+1], assuming capacity equals Engine.maxSections. However, skippedNodes capacity is captured when the context pool allocates it. Routes registered after a context is already created raise maxSections without resizing the pooled slice. The next request needing an additional backtrack frame panics with:
runtime error: slice bounds out of range inside the router before any middleware or handler.
Steps to Reproduce
- Register
GET /a and serve a warmup request (pooled context capacity = 1).
- Register additional nested routes:
GET /x/y/z/w, GET /x/y/:id/w, GET /x/:id/z/w, GET /:id/y/z/w.
- Serve
POST /x/y/z/w/extra with router.HandleMethodNotAllowed = true.
- Result:
panic: runtime error: slice bounds out of range [:2] with capacity 1.
Proposed Fix
Grow skippedNodes with append instead of raw reslicing.
A Pull Request addressing this is submitted concurrently.
Summary
getValuegrows the backtrack stack with a raw reslice(*skippedNodes)[:index+1], assuming capacity equalsEngine.maxSections. However,skippedNodescapacity is captured when the context pool allocates it. Routes registered after a context is already created raisemaxSectionswithout resizing the pooled slice. The next request needing an additional backtrack frame panics with:runtime error: slice bounds out of rangeinside the router before any middleware or handler.Steps to Reproduce
GET /aand serve a warmup request (pooled context capacity = 1).GET /x/y/z/w,GET /x/y/:id/w,GET /x/:id/z/w,GET /:id/y/z/w.POST /x/y/z/w/extrawithrouter.HandleMethodNotAllowed = true.panic: runtime error: slice bounds out of range [:2] with capacity 1.Proposed Fix
Grow
skippedNodeswithappendinstead of raw reslicing.A Pull Request addressing this is submitted concurrently.