Description
Issue Description
Hi there!
I've been using echo for a relatively large api service, upgrading from 3.x to the latest 4.x recently and fixing some issues along the way.
While the initial issue I ran into may be related to #1678 (some groups or routes randomly "forget" their handler and start returning 404's) I discovered some other issues in echo.
First I'd like to thank the maintainers for the project, I don't mind discussing this issue or attempting to contribute a fix.
Anyways, I noticed here a significant race condition introduced via #1535 .
echo.maxParam
cannot be changed safely, even with atomics (which would fix the data race), as the algorithm itself is racy.
Overwriting that value via the context I realized was causing panics here for me (not sure why that isn't just using the len of pvalues to begin with).
Further, manipulation of the context/echo types seems to lead to issues with the Find algorithm in the Router which is already hard to follow, and may be leading to my initial issue above.
Perhaps unrelated, is there a particular usage for the context type and methods I'm missing? It's defined as an interface but cannot be (re)implemented due to unsafe assertions such as this. I was hoping to override/shadow some methods for debugging purposes but cannot.
Thanks again, as for the initial issue I mentioned above regarding 404's I'd like to discuss/tackle after this one.
Checklist
- [ x] Dependencies installed
- Latest Go
- [ x] No typos
- [x ] Searched existing issues and docs
Expected behaviour
Safely use context methods
Actual behaviour
Panic from incorrect len / race.
Steps to reproduce
Noted above.
Version/commit
Latest echo release, v4.1.17. Note I haven't tried with master, I noticed ~50 commits to master since the last release, I briefly looked at them but didn't see anything that would fix this.