Home  >  Article  >  Backend Development  >  How to solve the problem of php script segmentation error

How to solve the problem of php script segmentation error

藏色散人
藏色散人Original
2020-09-12 09:17:262405browse

Solution to php script segmentation error: 1. Upgrade the PHP version; 2. Delete the "/etc/pki/nssdb/pkcs11.txt" and "/etc/pki/nssdb/cert9.db" files. Can.

How to solve the problem of php script segmentation error

Recommended: "PHP Video Tutorial"

PHP uses file_get_contents or curl to request https domain names. A segment fault error will occur.

The problem PHP code is as follows. A segment fault will occur when executing this PHP command:

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

Solution:

1. Upgrade your PHP version, In the 5.4 environment, the problem cannot be reproduced (the above execution code is 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. :-((The solution provided on Centos bugs is feasible after practice, but it will reappear soon after deleting it)

But Why does a segmentation fault occur?

PHP version:

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 system information:

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

By checking the kernel log and gdb record, you can find that the problem occurs on libsqlite

Kernel log:

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 record:

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

In the Centos bug list, you can find a description of this bug:

https://bugs.centos.org/view.php?id=7399
https://www.mankier.com/5/cert9.db

The above is the detailed content of How to solve the problem of php script segmentation error. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn