Closed poolpOrg closed 3 months ago
Thanks for this report. I am curious about your fix, could you share it? Thanks.
You just call fr := f.clone(!fork)
instead of fr := f.clone(fork)
at https://github.com/traefik/yaegi/blob/9aa161f2da6ef119d62d939ba113af8cad5c54b2/interp/run.go#L1899 right?
That's the most trivial way to get rid of the leak and confirm that it is the data being copied inside the frame clone that's leaking, I also had a couple different ways, none of which I'm convinced are correct.
Is the clone even needed ?
I'm sorry, I removed the details because I realized someone with an understanding of what the diff does could figure how to crash traefik instances with middlewares containing a specific yet very common pattern of code.
The following program
sample.go
triggers an unexpected resultExpected result
Got
It causes traefik OOM when running plugins on a machine with frequent goroutine spawns (ie: a ticker).
Yaegi Version
all versions >= 0.14.3
Additional Notes
This isn't a goroutine leak, as the goroutines count remains stable and it isn't a garbage collector contention as the garbage collector is in the same range of iterations.
I seem to have found the issue, currently studying the code base and the impact of a fix I came up with, hopefully a developer can get in touch with me. On the left is the leak observed, on the right is the same execution with my fix: