Open
Description
Description
The following code:
<?php
class Test {
public $lib;
public function __construct() {
$this->lib = \FFI::cdef("extern void setCloseSessionCallback(void(*fun)(unsigned long cid));
extern void testCloseSessionCallback();
", "./libsomelib.so");
}
}
$tclass = new Test();
$tclass->lib->setCloseSessionCallback(function($cid){
echo "ok\n";
});
$tclass->lib->testCloseSessionCallback(); //this function creates new std::thread from c++ stl, sleeps 2 seconds and calls function passed to setCloseSessionCallback
while(true); //prevent php script from completion because testCloseSessionCallback running in other thread
Resulted in this output:
segmentation fault (core dumped)
But I expected this output instead:
ok
PHP Version
PHP 8.0.21 (zts) with Zend OPcache v8.0.21
Operating System
Manjaro Linux