Open Damian19866 opened 1 year ago
can i work on this ??
This is a bug in the PHP interpreter. The error message indicates that the generator is already running when an attempt is made to resume it. This should not happen since a generator cannot be resumed if it is already running.
In the first code example, the issue seems to be caused by the generator and the fiber sharing the same event loop, which causes a race condition. When the fiber starts, it runs immediately and tries to resume the generator before the generator has a chance to suspend. This causes the generator to be already running when it is resumed, resulting in the error message.
In the second code example, there is a memory corruption issue. It appears that the generator is freed while the fiber is still using it, leading to a heap-use-after-free error. This may be caused by the same race condition as in the first example.
To fix the issue, the generator and the fiber should not share the same event loop. They should be created in separate contexts to avoid race conditions. Additionally, the generator should be properly cleaned up before it is freed to avoid memory corruption issues.
It is recommended to report this bug to the PHP developers so that it can be fixed in a future release.
Description
The following code:
Resulted in this output (in Unknown on line 0 is also very helpful to track the issue down...):
But I expected this output instead:
It seems necessary to add some ordering constraint within the interaction of fibers and generators. (Swapping the creation of the generator and the fiber in this example poses no problems.)
Similarly there is a crash in a slight variation of this code (without finally):
Resulting in:
PHP Version
master
Operating System
No response
Originally posted by @bwoebi in https://github.com/php/php-src/issues/9916