我发现了一种使php segfault的方法,我对发生了什么感到有点好奇。也许有人能给我解释一下?
joern@xps:..com/trunk5/tools/nestedset> cat > while.php
<?php
while(1){
die('dd');
}
?>
^C
0 joern@xps:..com/trunk5/tools/nestedset> php -f while.php
ddzsh: segmentation fault php -f while.php
0 joern@xps:..com/trunk5/tools/nestedset> php -f while.php
dd%
0 joern@xps:..com/trunk5/tools/nestedset> php -f while.php
dd%
0 joern@xps:..com/trunk5/tools/nestedset> php -f while.php
ddzsh: segmentation fault php -f while.php
0 joern@xps:..com/trunk5/tools/nestedset> php -f while.php
ddzsh: segmentation fault php -f while.php
0 joern@xps:..com/trunk5/tools/nestedset> php -f while.php
dd%
0 joern@xps:..com/trunk5/tools/nestedset> php -f while.php
dd% 正如您所看到的,并不是每次都会发生这种情况。Php缓存?
php5 5.2.10.dfsg.1-2ubuntu6.1发布于 2009-11-20 15:03:58
Wikipedia: Segmentation Fault
一些研究表明,一些PHP扩展可能玩得不好,或者彼此之间玩得不好。它还可以取决于服务器或服务器配置。
如果你同时使用同时加载的XDebug和Zend Debugger,可能会导致这种情况。
一开始,我认为与die()语句一起使用的while循环可能是原因的一部分。我很想知道这是否也会导致分割错误:
while (!$fault) {
$fault=check_fault_function();
}
if ($fault) { die('dd'); }如果不是,这可能就是你们如何使用while和die。如你所知,虽然(1) {}是一个无限循环...(您的服务器可能不知道如何为无限的例程分配内存),因此,除非您试图导致崩溃,否则这通常是不好的做法。
发布于 2009-11-23 10:06:01
这似乎与PHP源代码中的一个已知错误有关。它已经在PHP主干中得到了修复,看起来它是在5.2.11发布前后推出的。详细信息请参见here和here。
https://stackoverflow.com/questions/1763334
复制相似问题