[php-src] Issue #9214: Segmentation fault when calling callback function

From: Date: Sun, 31 Jul 2022 22:35:05 +0000
Subject: [php-src] Issue #9214: Segmentation fault when calling callback function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-242091@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/9214 Author: fwflunky ### Description The following code: ```php <?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 ``` gdb backtrace: ![image](https://user-images.githubusercontent.com/38854160/182047756-fd507332-e72d-4103-b277-c453afc5ee1d.png) ### PHP Version PHP 8.0.21 (zts) with Zend OPcache v8.0.21 ### Operating System Manjaro Linux

« previous php.bugs (#242091) next »