Bug #74120 [Opn]: SyncEvent fires only when someone is waiting
| From: | cubic@php.net | Date: | Sat, 18 Feb 2017 03:11:24 +0000 |
| Subject: | Bug #74120 [Opn]: SyncEvent fires only when someone is waiting | ||
| References: | 1 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-14517@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=74120&edit=1
ID: 74120
Updated by: cubic@php.net
Reported by: amancio at prjc dot com dot br
Summary: SyncEvent fires only when someone is waiting
Status: Open
Type: Bug
Package: PECL
Operating System: Linux
PHP Version: 5.6.30
-Assigned To:
+Assigned To: cubic
Block user comment: N
Private report: N
New Comment:
I am unable to replicate the problem on Ubuntu Linux. However, after staring at the logic for a
while, I did find two semi-related bugs with the underlying event object implementation. But
neither bug should have triggered in a truly isolated setup.
It would help me to know what var_dump($event->fire()) returns. Useful tip: var_dump() is
frequently easier than writing if/else logic.
What flavor of Linux are you running? There are subtle differences in POSIX implementations across
even the most common Linux distros.
Does the object exist in /dev/shm/? What permissions does it have (should be 0666)? If you delete
the object manually, does the test start working as expected?
Also of note: ext/sync/tests/011.phpt runs named manual event objects through its paces as best as
a single process can test them. You should run the test suite to see if there are other object
types broken on your platform. This command should work:
pecl run-tests -p sync
Previous Comments:
------------------------------------------------------------------------
[2017-02-17 15:38:27] cubic@php.net
Thanks for the bug report and test case. Looks like a probable regression in manual reset event
objects. I'll look into this.
Note that any bugs in the PECL package will almost always reflect over here:
https://github.com/cubiclesoft/cross-platform-cpp
Version 1.1.0 represents a major rewrite to bypass POSIX semaphore issues on some platforms (e.g.
Mac) and added support for PHP 7. Windows saw no significant changes other than PHP 7 support.
That at least explains why any regressions took place.
------------------------------------------------------------------------
[2017-02-17 13:58:25] amancio at prjc dot com dot br
Description:
------------
Using package 'sync' PECL extension;
When an instance of SyncEvent calls fire() in a thread, the other instance of SyncEvent just gets
fired if it is executing wait(). If the thread is processing other things, the next call to wait()
will wait indefinitely.
This bad behaviour was observed just on Linux with sync 1.1.0. On Windows, sync 1.1.0 behaves
correctly (the next call to wait() knows the event was already fired). Sync 1.0.1 (the previous
version) behaves correctly on both platforms, Windows and Linux.
Test script:
---------------
// a single-threaded example:
$event = new SyncEvent("Test-123", true);
$event->fire();
if ($event->wait(0))
echo "Fired, ok";
else
echo "Not fired?";
Expected result:
----------------
On any platform, any version should have to print "Fired, ok".
Actual result:
--------------
On Windows, Sync 1.0.1 and 1.1.0 prints "Fired, ok".
On Linux, Sync 1.0.1 prints "Fired, ok", but Sync 1.1.0 prints "Not fired?".
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=74120&edit=1