PHP请求https域名发生segment fault段错误

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/loophome/article/details/53812887

PHP使用file_get_contents或curl请求https的域名均会发生segment fault的错误。

问题PHP代码如下,执行该PHP命令会发生segment fault:

var_dump(file_get_contents("https://www.baidu.com"));


解决方案:

1. 升级你的PHP版本,在5.4环境下,未能重现改问题(以上执行代码是PHP5.2)

2. Sadly, this has not been the case. Removing /etc/pki/nssdb/pkcs11.txt and /etc/pki/nssdb/cert9.db seem to be the key, here. :-((Centos bugs上提供的解决方案,实践后 可行,但是删掉了不久后会重新出现)


但是为什么会发生段错误呢?


PHP版本:

PHP 5.2.14 (cli) (built: Jul  3 2016 23:56:15)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    with eAccelerator v1.0-dev, Copyright (c) 2004-2012 eAccelerator, by eAccelerator

Linux系统信息:

LSB Version:    :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.3 (Final)
Release:        6.3
Codename:       Final


通过查看内核日志和gdb记录,可以发现问题出现在libsqlite上

内核日志:

tail -f /var/log/messages
kernel: php[26564]: segfault at 8048 ip 00007f7a72fede9c sp 00007fffec90edf0 error 4 in libsqlite3.so.0.8.6[7f7a72fd1000+8c000]

gdb记录:

Program received signal SIGSEGV, Segmentation fault.
0x00007fffe9651e9c in sqlite3_file_control () from /usr/lib64/libsqlite3.so.0


在Centos的bug列表中,能够找到关于这个bug的说明:

https://bugs.centos.org/view.php?id=7399

https://www.mankier.com/5/cert9.db



没有更多推荐了,返回首页