Invalid file descriptor exceptions on PHP 7.2
Issue #49
resolved
With the latest version, PHP 7.2 throws "Invalid file descriptor" exceptions, while the same code works fine with the extension on PHP 7.1 and 7.0.
Comments (6)
-
reporter -
repo owner - changed status to on hold
Please provide a code to reproduce the issue. (Preferably minimal.)
-
reporter <?php require __DIR__ . '/vendor/autoload.php'; $loop = new class { private $handle; private $ioCallback; private $events; public function __construct() { $this->handle = new EventBase; $this->ioCallback = function () { var_dump(__FILE__ . ':' . __LINE__); }; } public function watch($stream) { $this->events[(int) $stream] = $event = new Event( $this->handle, $stream, Event::READ | Event::PERSIST, $this->ioCallback, null ); $event->add(); } public function run() { $this->handle->loop(true); } }; $loop->watch(STDOUT); $loop->run();
-
repo owner - changed status to resolved
Fixed
#49: Invalid file descriptor exceptionsFixed bug where 'Invalid file descriptor' exceptions were thrown in PHP 7.2. Due to Zend API changes in PHP 7.2, Event stream arguments were accepted by reference.
→ <<cset 11ad36b134df>>
-
repo owner $this->handle->loop(true);
Note that
EventBase::loop
method accepts integer flags, but you are passing booleantrue
. -
reporter Indeed, that's just a bad copy from https://github.com/amphp/amp/blob/d561cc9736bc18dd94a2fc9cdae98b616bd92c43/lib/Loop/EventDriver.php#L191 for the minimal driver. Thanks for fixing!
- Log in to comment
I just verified again that everything works fine with PHP 7.1 with both
ext-event
2.3.0 and 2.4.0RC1, but fails on PHP 7.2.1 withext-event
2.4.0RC1, while it works fine with PHP 7.2.1 andext-event
2.3.0.