0

Really strange thing happening on PHP 8 fpm (using anything Eloquent triggers it) and unable to debug the coredump (PHP 7.3 is ok)

Environment is Debian 10 (Vagrant VM and also DO droplet)

  • Vagrant php -v shows PHP 8.0.3
  • DO droplet php -v shows PHP 8.0.5

Composer shows and just did a composer global update

...
  "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) code works in php7.4-fpm (normal setup of nginx + fpm) If there is a syntax error, the browser shows a nice web page with the error (and link to telescope)

Nginx + php8.0-fpm

Most of the "simple" PHP pages work (a quick phpinfo.php also works fine) .. however it starts showing "502 Bad Gateway" (nginx) when you click on submit on the login page of https://laravel.com/docs/8.x/starter-kits#laravel-breeze (it shows the initial form)

This is only happening on php8.0-fpm (using a Vagrant VM and also replicated on a DO droplet)

Something is causing php8.0-fpm to SIGSEGV (signal 11). It doesn't even hit the laravel logs and nginx displays "502 Bad Gateway" (standard nginx error page) from the response of php8.0-fpm

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

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

I have been able to generate core dumps, however the bt is not showing much information. The core dumps (on a vagrant VM) is over 200MB (huge file for a page refresh?) and this goes from #0 to #38286 (lots and lots of lines) with pretty much the same stuff with no function like I was expecting to see (function or frame) and it seems to be in an infinite loop ...

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 ()

On the code side, I have been able to isolate it to perhaps Eloquent but the database is working

The following lines work

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

but then adding the following gets the SIGSEGV

$user = User::find(10001);

or

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

Any ideas? Maybe downgrade back to php 7.4 (which does not seem like a good way to go)

Maybe it is how php 8 is handling the errors vs exceptions?

Chris Go
  • 599
  • 6
  • 19
  • Looks like It looks like this is an infinite loop caused by this library (use for lowerCamelCasing the model properties) https://github.com/jarektkaczyk/eloquence (dev-master) Commenting out the trait in the model `//use Eloquence;` does **NOT** generate the SIGSEGV Specifically, looks like this issue https://github.com/jarektkaczyk/eloquence/issues/265 But works on PHP 7.4 Strangely enough, there is another library that looks like a fork (but not really a fork?) https://github.com/kirkbushell/eloquence Maybe there is another way to lowerCamelCase the model properties? – Chris Go May 06 '21 at 18:05
  • For 502, can you try `sudo service php7.4-fpm restart` using your SSH access? – nice_dev May 06 '21 at 18:18
  • 1
    How did you generate the dump and understand where the rpbolem is, i am suffering with same issue – Kristi Jorgji Jul 30 '21 at 10:13
  • We are noticing this intermittently on a single route in Laravel 9 + PHP 8 – Amit Chandrashekar Singh Jan 05 '23 at 15:58
  • In my case I have problems with jit. Do you have `opcache.jit_buffer_size` and `opcache.jit` in your php opcache config ? I removed jit for the moment and it works. – John Mar 20 '23 at 10:06

1 Answers1

0

I had the same problem. In my case one of my composer packages was not php 8 compatible (eloquence). To find the failing package that uses to much memory, I had to composer remove every package one by one, test it, re-enable it again, and do the next one, until it worked... I know this is a pain to do, but it was the only method I know on how to discover this.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Daantje
  • 2,406
  • 25
  • 26