Closed Blackjack200 closed 1 year ago
$u is not defined anywhere
$u is not defined anywhere
Of course,
$u = 1;
$t = (new A(static fn() => static function() use (&$u) : void {
echo "HI 2\n";
var_dump($u);
$u=10;
}));
$t->start(Thread::INHERIT_COMMENTS);
$t->join();
var_dump($u);
this outputs
HI 1
HI 2
int(1)
int(1)
&$u is a copy of $u
Can you try disabling xdebug (remove the line zend_extension=xdebug.so
from php.ini
)?
This happens because an IS_UNDEF
zval appears in the static_variables
table, which is quietly skipped by this foreach:
https://github.com/pmmp/ext-pmmpthread/blob/95bf23c9e309c5f945d7d8fa5c5b291b54365fa7/src/copy.c#L104
Technically speaking, it shouldn't actually make it this far in the first place (evidently we are missing nested closure thread-safety checks), but this bug will probably show up in other places too.
Environment
PHP:
Version => 6.0.1
Windows 10 22H2, Intel Core i5 12490f
yes
no
Reproducing Code
Expected Output
or something like
Actual Output
in PHPStorm: