You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By the way @dstogov, this issue can be easily reproduced without even using network I/O by running the composite cancellation benchmark in https://github.com/amphp/amp:
OK I think I found the cause, the code in the AbstractDriver class is referencing the $callbacks property of the child class UvDriver, not the $callbacks property in AbstractDriver: renaming it in UvDriver fixes the issue.
I had to increase the loop count to 100 to be able to reliably reproduce it.
I think you're right it's the same root cause, as my PR #12381 also seems to fix this.
Yep, however the phpunit testsuite still seems to fail with your fix if ASAN is enabled (not a JIT bug tho)...
@danog That's not a bug. If you use ASAN and disable the Zend memory allocator (which you need to do for ASAN to work properly), then memory_get_usage() doesn't work. That function will always return 0 because you bypass Zend's memory manager.
As the CompositeCancellationTest only performs assertions when the memory usage returned by that function is higher than zero, the assertion can never execute. Hence, phpunit reports a risky test because no assertions happened.
Actually I was referring to this phpunit failure in amphp/parallel:
1) Amp\Parallel\Test\Worker\ProcessPoolTest::testSubmitMultipleThenShutdown
Amp\Parallel\Context\ContextException: The context stopped responding, potentially due to a fatal error or calling exit
Which is caused by a crash of the worker process only when ASAN is used, trying to look into it...
Turns out it's just a timeout caused by the slowdown in ASAN, which causes the connection attempts in src/Context/Internal/functions.php to start before the IPC hub starts listening on the UNIX socket, ping @trowski
Activity
[-]Hang when using amphp/parallel and tracing JIT[/-][+]Hang when using amphp and tracing JIT[/+]danog commentedon Oct 6, 2023
By the way @dstogov, this issue can be easily reproduced without even using network I/O by running the composite cancellation benchmark in https://github.com/amphp/amp:
danog commentedon Oct 7, 2023
@dstogov Finally managed to narrow it down to this specific closure execution: https://github.com/revoltphp/event-loop/blob/main/src/EventLoop/Internal/AbstractDriver.php#L593
Replacing that line with a call_user_func fixes the issue.
Replacing https://github.com/revoltphp/event-loop/blob/main/src/EventLoop/Internal/AbstractDriver.php#L86 with an indirect closure
function (Closure $i): void { $this->setInterrupt($i); }also seems to fix the issue.danog commentedon Oct 7, 2023
It seems like the actual source of the problem is https://github.com/revoltphp/event-loop/blob/main/src/EventLoop/Internal/AbstractDriver.php#L565, the if is entering when it shouldn't, in fact adding the following assertion fails:
danog commentedon Oct 7, 2023
In fact it's just the isset, splitting the if just this code can trigger the assertion:
danog commentedon Oct 7, 2023
Very strangely, the first few runs after modifying the file don't trigger the assertion (something to do with mtime maybe?)
danog commentedon Oct 7, 2023
The affected trace seems to be trace 311 from the debug output, the zend bytecode seems correct, let's see if I can find the assembly...
https://paste.daniil.it/debug_run
danog commentedon Oct 7, 2023
Simpler reproducer:
danog commentedon Oct 7, 2023
OK I think I found the cause, the code in the AbstractDriver class is referencing the
$callbacksproperty of the child class UvDriver, not the$callbacksproperty in AbstractDriver: renaming it in UvDriver fixes the issue.ndossche commentedon Oct 8, 2023
I had to increase the loop count to 100 to be able to reliably reproduce it.
I think you're right it's the same root cause, as my PR #12381 also seems to fix this.
danog commentedon Oct 8, 2023
Yep, however the phpunit testsuite still seems to fail with your fix if ASAN is enabled (not a JIT bug tho)...
ndossche commentedon Oct 8, 2023
@danog That's not a bug. If you use ASAN and disable the Zend memory allocator (which you need to do for ASAN to work properly), then
memory_get_usage()doesn't work. That function will always return 0 because you bypass Zend's memory manager.As the
CompositeCancellationTestonly performs assertions when the memory usage returned by that function is higher than zero, the assertion can never execute. Hence, phpunit reports a risky test because no assertions happened.danog commentedon Oct 8, 2023
Actually I was referring to this phpunit failure in amphp/parallel:
Which is caused by a crash of the worker process only when ASAN is used, trying to look into it...
danog commentedon Oct 8, 2023
Turns out it's just a timeout caused by the slowdown in ASAN, which causes the connection attempts in
src/Context/Internal/functions.phpto start before the IPC hub starts listening on the UNIX socket, ping @trowskidanog commentedon Oct 8, 2023
Oh and also ping @trowski, mind reporting that bus error segfault you were getting on mac with JIT when running
php examples/async.phpin amphp/amp?ndossche commentedon Oct 9, 2023
Fixed via #12381. Feel free to report the other bus error issue though, preferably in a separate issue though :-)