|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2019-05-22 07:50 UTC] nikic@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
Description: ------------ When use "pcntl_async_signals(true)" and try to access the magic property from async signal handler and regular way in same time, get error "Undefined property". PHP 7.1 7.2 7.3: docker run -it --rm -v "$PWD":/app php:7.1.29-cli sh -c "docker-php-ext-install -j"$(getconf _NPROCESSORS_ONLN)" pcntl && php /app/test-magic.php" docker run -it --rm -v "$PWD":/app php:7.2.18-cli sh -c "docker-php-ext-install -j"$(getconf _NPROCESSORS_ONLN)" pcntl && php /app/test-magic.php" docker run -it --rm -v "$PWD":/app php:7.3.5-cli sh -c "docker-php-ext-install -j"$(getconf _NPROCESSORS_ONLN)" pcntl && php /app/test-magic.php" Test script: --------------- <?php //test-magic.php $obj = new TestMagic; $childrenCount = 100; $completed = 0; pcntl_async_signals(true); set_error_handler(static function (int $errNo, string $errStr) { throw new \ErrorException("ERROR #{$errNo}: {$errStr}"); }); pcntl_signal(SIGINT, static function () {exit;}); pcntl_signal(SIGTERM, static function () {exit;}); pcntl_signal(SIGCHLD, static function () use ($obj, &$completed) { $completed++; echo "ASYNC ACCESS #{$completed} "; echo "{$obj->x}\n"; }); $inRun = 0; while (++$inRun <= $childrenCount) { proc_open('sleep ' . (random_int(1, 999) / 1000), [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes); } while ($completed < $childrenCount) { echo "BLOCKING ACCESS #{$completed} "; echo "{$obj->x}\n"; } /** @property $x */ class TestMagic { public function __set($name, $value) { return null; } public function __get($name) { return 'OK'; } public function __isset($name) { return true; } } // ... // BLOCKING ACCESS #5 OK // BLOCKING ACCESS #5 ASYNC ACCESS #6 // Fatal error: Uncaught ErrorException: ERROR #8: Undefined property: TestMagic::$x in /app/test-magic.php:9 // Stack trace: // #0 /app/test-magic.php(17): {closure}(8, 'Undefined prope...', '/app/test-magic...', 17, Array) // #1 /app/test-magic.php(41): {closure}(17, Array) // #2 /app/test-magic.php(27): TestMagic->__get('x') // #3 {main} // thrown in /app/test-magic.php on line 9 // Segmentation fault (core dumped)