-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Cycle detection doesn't work well with fibers #1752
Comments
Given that concurrency isn't really the default model for PHP still, for now you'd need to call |
Fibers each have their own call stack. Fiber locals are basically variables bound to a specific fiber, so a bit like |
We keep a separate depth count per fiber. Fixes Seldaek#1752.
* Fix cycle detection within fibers We keep a separate depth count per fiber. Fixes #1752. * Avoid additional call to Fiber::getCurrent() Suppresses phpstan errors, as they're false positives.
Cycle detection is broken when using fibers, because it assumes that if the function is entered multiple times, it's a cycle. With fibers, the function might be entered multiple times in different fibers if one of them suspends somewhere within the function.
What are your thoughts to moving cycle detection to an interface? There could be a
NullCycleDetector
that doesn't detect cycles at all, aCountingCycleDetector
and then aFiberLocal
based implementation that keeps track of the depth for each fiber separately. I'm of course also fine with fibers being supported natively, but I don't think it's a good idea to put this logic intoLogger
itself in that case.The text was updated successfully, but these errors were encountered: