使用GDB调试PHP代码,解决PHP代码死循环
最近在帮同事解决Swoole Server问题时,发现有1个worker进程一直处于R的状态,而且CPU耗时非常高。初步断定是PHP代码中发生死循环。下面通过一段代码展示如何解决PHP死循环问题。[code lang="php"#dead_loop.ph$array = array();for($i = 0; $i < 10000; $i$array[] = $i;include __DIR__."/include#include.phwhile(1usleep(10);$keys = array_flip($array);$index = array_search(rand(1500, 9999), $array);$str = str_repeat('A', $index);$strb = test($index, $str);function test($index, $str... Read More