首页 > 解决方案 > Laravel + PHP 8 fpm SIGSEGV(信号 11)

问题描述

PHP 8 fpm 上发生了非常奇怪的事情(使用任何 Eloquent 触发它)并且无法调试 coredump(PHP 7.3 可以)

环境是 Debian 10(Vagrant VM 和 DO droplet)

作曲家表演,刚刚做了作曲家全局更新

...
  "require": {
        "php": "^7.3|^8.0",
        "aws/aws-sdk-php": "^3.176",
        "barryvdh/laravel-cors": "^2.0",
        "barryvdh/laravel-debugbar": "^3.5",
        "barryvdh/laravel-ide-helper": "^2.9",
        "barryvdh/laravel-snappy": "^0.4.8",
        "beyondcode/laravel-dump-server": "^1.7",
        "dyrynda/laravel-nullable-fields": "^4.1",
        "fideloper/proxy": "^4.4",
        "fruitcake/laravel-cors": "^2.0",
        "google/apiclient": "^2.",
        "guzzlehttp/guzzle": "^7.3",
        "hashids/hashids": "^4.1",
        "laracasts/flash": "^3.2",
        "laravel/cashier": "^12.10",
        "laravel/framework": "^8.40",
        "laravel/horizon": "^5.7",
        "laravel/sanctum": "^2.9",
        "laravel/scout": "^8.6",
        "laravel/socialite": "^5.2",
        "laravel/telescope": "^4.4",
        "laravel/tinker": "^2.6",
        "laravel/ui": "^3.2",
        "laravelcollective/html": "^6.2",
        "league/csv": "^9.7",
        "league/flysystem-aws-s3-v3": "^1.0",
        "phery/phery": "^2.7",
        "php-parallel-lint/php-console-color": "^1.0",
        "plivo/plivo-php": "^4.18",
        "predis/predis": "^1.1",
        "sofa/eloquence": "dev-master",
        "vinkla/hashids": "^9.1",
        "wildbit/postmark-php": "^4.0",
        "wildbit/swiftmailer-postmark": "^3.3"
  },
  "require-dev": {
        "facade/ignition": "^2.5",
        "fakerphp/faker": "^1.9.1",
        "laravel/breeze": "^1.1",
        "laravel/sail": "^1.0.1",
        "mockery/mockery": "^1.4.2",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3.3"
    },

Nginx + php7.4-fpm

Laravel (PHP) 代码在 php7.4-fpm 中工作(nginx + fpm 的正常设置)如果有语法错误,浏览器会显示一个带有错误的漂亮网页(并链接到望远镜)

Nginx + php8.0-fpm

大多数“简单”的 PHP 页面都可以工作(一个快速的 phpinfo.php 也可以正常工作).. 但是当您在https://laravel.com的登录页面上单击提交时,它开始显示“502 Bad Gateway”(nginx)/docs/8.x/starter-kits#laravel-breeze(它显示初始形式)

这仅在php8.0-fpm上发生(使用 Vagrant VM 并在 DO 液滴上复制)

某些东西导致 php8.0-fpm 到 SIGSEGV(信号 11)。它甚至没有命中 laravel 日志,并且 nginx 从 php8.0-fpm 的响应中显示“502 Bad Gateway”(标准 nginx 错误页面)

/var/log/php8.0-fpm.log

WARNING: [pool www] child 3956 exited on signal 11 (SIGSEGV - core dumped) after 63.502325 seconds from start

我已经能够生成核心转储,但是bt没有显示太多信息。核心转储(在 vagrant VM 上)超过 200MB(用于页面刷新的巨大文件?),这从 #0 到 #38286(很多很多行)几乎相同,但没有我期望的功能看到(功能或框架),它似乎是在一个无限循环......

Reading symbols from /usr/sbin/php-fpm8.0...(no debugging symbols found)...done.
[New LWP 3956]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `php-fpm: pool www                                                            '.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000056483469fa4e in zend_is_callable_at_frame ()
(gdb) bt
#0  0x000056483469fa4e in zend_is_callable_at_frame ()
#1  0x00005648346a09a7 in zend_is_callable_ex ()
#2  0x00005648346a0adc in zend_fcall_info_init ()
#3  0x00005648345ca7ec in ?? ()
#4  0x0000564834701268 in execute_ex ()
#5  0x000056483468c5d2 in zend_call_function ()
#6  0x00005648345ca820 in ?? ()
#7  0x0000564834701268 in execute_ex ()
#8  0x000056483468c5d2 in zend_call_function ()
#9  0x00005648345ca820 in ?? ()
#10 0x0000564834701268 in execute_ex ()
#11 0x000056483468c5d2 in zend_call_function ()
#12 0x00005648345ca820 in ?? ()
...
#38280 0x00005648345ca820 in ?? ()
#38281 0x0000564834701268 in execute_ex ()
#38282 0x0000564834702c3c in zend_execute ()
#38283 0x0000564834699e0d in zend_execute_scripts ()
#38284 0x0000564834636b0b in php_execute_script ()
#38285 0x00005648344f0109 in ?? ()
#38286 0x00007f7c0e98109b in __libc_start_main (main=0x5648344ef280, argc=4, argv=0x7ffd1785e398, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7ffd1785e388) at ../csu/libc-start.c:308
#38287 0x00005648344f0f1a in _start ()

在代码方面,我已经能够将它隔离到 Eloquent 但数据库正在运行

以下几行有效

$users = DB::table('users')->get();
//dd($users);
echo count($users);  // show 31

但随后添加以下内容会得到SIGSEGV

$user = User::find(10001);

或者

$users = User::all(); // only 31 records in the database

有任何想法吗?也许降级回 php 7.4(这似乎不是一个好方法)

也许这就是 php 8 处理错误与异常的方式?

标签: phplaravelfpm

解决方案


我有同样的问题。在我的情况下,我的一个作曲家包与 php 8 不兼容(雄辩)。为了找到使用大量内存的失败包,我必须composer remove一个一个地测试每个包,测试它,重新启用它,然后再做下一个,直到它起作用......我知道这样做很痛苦,但这是我知道如何发现这一点的唯一方法。


推荐阅读