<?php
use pmmp\thread\Thread;
use pmmp\thread\ThreadSafeArray;
class testThread extends Thread{
private ThreadSafeArray $config;
public function __construct(ThreadSafeArray $config){
$this->config = $config;
}
public function getConfig(): array{
return (array)$this->config;
}
public function run(): void{
var_dump($this->getConfig()['protocol']["INVALID_KEYgeneral"]); //UNKNOWN:0
var_dump($this->getConfig()['protocol']["INVALID_KEYgeneral"][0]); //segfault
}
}
(new testThread(ThreadSafeArray::fromArray(["protocol" => []])))->start(Thread::INHERIT_ALL);
Expected Output
Unknown
Actual Output
See comments.
Warning: PHP Startup: Invalid date.timezone value 'BST', using 'UTC' instead in Unknown on line 0
UNKNOWN:0
Process 86263 stopped
* thread #4, stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
frame #0: 0x0000000100934770 php`zval_undefined_cv(var=96, execute_data=0x0000000104414020) at zend_execute.c:270:21
267 static zend_never_inline ZEND_COLD zval* zval_undefined_cv(uint32_t var EXECUTE_DATA_DC)
268 {
269 if (EXPECTED(EG(exception) == NULL)) {
-> 270 zend_string *cv = CV_DEF_OF(EX_VAR_TO_NUM(var));
271 zend_error(E_WARNING, "Undefined variable $%s", ZSTR_VAL(cv));
272 }
273 return &EG(uninitialized_zval);
Target 0: (php) stopped.
Extras
(lldb) bt
* thread #4, stop reason = EXC_BAD_ACCESS (code=1, address=0x8)
* frame #0: 0x0000000100934770 php`zval_undefined_cv(var=96, execute_data=0x0000000104414020) at zend_execute.c:270:21
frame #1: 0x0000000100933cb4 php`_zval_undefined_op1(execute_data=0x0000000104414020) at zend_execute.c:278:9
frame #2: 0x0000000100874978 php`zend_fetch_dimension_address_read(result=0x0000000104414070, container=0x0000000104414080, dim=0x00000001188bed20, dim_type=8, type=0, is_list=false, slow=1, execute_data=0x0000000104414020) at zend_execute.c:2757:16
frame #3: 0x0000000100942258 php`zend_fetch_dimension_address_read_R_slow(container=0x0000000104414080, dim=0x00000001188bed20, opline=0x00000001188beec0, execute_data=0x0000000104414020) at zend_execute.c:2779:2
frame #4: 0x000000010092f14c php`ZEND_FETCH_DIM_R_INDEX_SPEC_TMPVAR_CONST_HANDLER(execute_data=0x0000000104414020) at zend_vm_execute.h:16255:3
frame #5: 0x0000000100879f98 php`execute_ex(ex=0x0000000104414020) at zend_vm_execute.h:55835:7
frame #6: 0x00000001008141d4 php`zend_call_function(fci=0x000000016ff9ec10, fci_cache=0x000000016ff9ec50) at zend_execute_API.c:947:3
frame #7: 0x000000010046cf54 php`pmmpthread_routine_run_function(connection=0x0000000104468100) at routine.c:68:5
frame #8: 0x000000010046c820 php`pmmpthread_routine(routine=0x000000016fdfdf30) at routine.c:113:8
frame #9: 0x00000001898bffa8 libsystem_pthread.dylib`_pthread_start + 148
Look who's backkkkk, I hate threads 🥲ðŸ˜
Environment
PHP 8.2.8 (cli) (built: Aug 22 2023 00:59:03) (ZTS DEBUG)
Version => 6.0.8
Mac M1
no
n/a
Reproducing Code
Expected Output
Unknown
Actual Output
See comments.
Extras