In my plugin, plugin schedules process() repeating on every tick. PHP: public function process(){ echo "called\nhandlePacket()\n"; $work = false; if($this->handlePacket()){ $work = true; while($this->handlePacket()); } echo "pushInternalQueue()\n"; $this->pushInternalQueue([chr(Info::SIGNAL_TICK)]); echo "done tick\n"; } and pushInternalQueue sends Info::SIGNAL_TICK(0xf0) to Internal thread, and My another thread gets that in Thread::run() PHP: public function run(){ $this->logInfo("Thread started."); while($this->shutdown === false){ echo "tick!()\n"; if(strlen($buffer = $this->readInternalQueue()) > 0){ echo "switch!\n"; switch(ord($buffer{0})){ case Info::SIGNAL_UPDATE: break; case Info::SIGNAL_SHUTDOWN: $this->shutdown = true; break; case Info::SIGNAL_TICK: //TODO break; } } echo "tickend!\n"; } $this->logEmergency("Thread stopped!"); } (Note: the two codes are executed in diffrent thread.) Buf if I create the Thread(second code) and registers tick schedule(first code), console prints like this: Code: tick!() tickend! tick!() tickend! tick!() tickend! tick!() tickend! called handlePacket() tick!() pushInternalQueue() tickend! tick!() tickend! tick!() tickend! tick!() tickend! tick!() tickend! tick!() tickend! tick!() tickend! tick!() tick!() tickend! tick!() tickend! tick!() pushInternalQueue() start tickend! tick!() pushInternalQueue() done done tick (Sorry for dirty echo function, but I had to debug where the trouble is...) It seems like when I send SIGNAL_TICK to another thread with threaded internalQueue custom thread crashes the server. If I don't register tick schedule to call process(), server doesn't print segfault and stop. Is this problem caused by internal pthreads extension bug? Or my mistake? Can threaded internalQueue contain array? (Raklib's internal/external queue contains only string, but I tried to contain an array for convenience)
If you want to see entire source code, see https://github.com/if-Team/CustomPacket/tree/core-rewrite/plugin but there's some Korean stuffs in there...(like commit descriptions)
Eww, I found I overwritten the Threaded object to string, just forgot to use $this->internalQueue[] = $buffer; instead of $this->internalQueue = $buffer;