laravel / pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.
https://pulse.laravel.com
MIT License
1.43k stars 165 forks source link

PHP crashes with SIGSEGV #128

Closed afoster closed 10 months ago

afoster commented 10 months ago

Pulse Version

1.0.0-beta2

Laravel Version

10.34.2

PHP Version

8.2.8

Database Driver & Version

MariaDB 10.11 under Docker on arm64 (Mac)

Description

My app is running as a docker-compose project. I have an "app" container based on php:8.2-fpm-bullseye and it sits behind a reverse proxy container based on nginx:alpine.

Shortly after running composer require laravel/pulse and browsing to the /pulse route, PHP processes under php-fpm start crashing:

2023-12-04 13:31:58 [04-Dec-2023 02:31:58] WARNING: [pool www] child 1653 exited on signal 11 (SIGSEGV) after 23.091227 seconds from start

Eventually all children die, and the app is inaccessible (nginx throws 502 instantly on all requests).

php artisan about

  Environment ...........................................................................................  
  Application Name .................................................................................. BPM  
  Laravel Version ............................................................................... 10.34.2  
  PHP Version ..................................................................................... 8.2.8  
  Composer Version ................................................................................ 2.5.8  
  Environment ..................................................................................... local  
  Debug Mode .................................................................................... ENABLED  
  URL .................................................................................... localhost:9002  
  Maintenance Mode .................................................................................. OFF  

  Cache .................................................................................................  
  Config ..................................................................................... NOT CACHED  
  Events ..................................................................................... NOT CACHED  
  Routes ..................................................................................... NOT CACHED  
  Views .......................................................................................... CACHED  

  Drivers ...............................................................................................  
  Broadcasting ................................................................................... pusher  
  Cache ........................................................................................... redis  
  Database ........................................................................................ mysql  
  Logs ................................................................................... stack / single  
  Mail ............................................................................................. smtp  
  Queue ........................................................................................... redis  
  Session .......................................................................................... file  

  Livewire ..............................................................................................  
  Livewire ....................................................................................... v3.2.3  

composer.json

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^8.1",
        "beyondcode/laravel-websockets": "^1.14",
        "bpm/dashboard": "@dev",
        "ebess/advanced-nova-media-library": "^4.1",
        "guzzlehttp/guzzle": "^7.2",
        "kiritokatklian/nova-permission": "^4.0",
        "laravel/framework": "^10.13",
        "laravel/nova": "4.23.0",
        "laravel/passport": "^11.5",
        "laravel/pulse": "^1.0@beta",
        "laravel/tinker": "^2.8",
        "laravel/ui": "^4.2",
        "league/flysystem-aws-s3-v3": "^3.0",
        "php-ffmpeg/php-ffmpeg": "^1.1",
        "phpoffice/phpspreadsheet": "^1.15",
        "predis/predis": "^1.1",
        "pusher/pusher-php-server": "^7.2",
        "simplesoftwareio/simple-qrcode": "~4",
        "spatie/laravel-medialibrary": "^10.7",
        "spatie/laravel-permission": "^5.8"
    },
    "require-dev": {
        "mockery/mockery": "^1.4.4",
        "nunomaduro/collision": "^7.0",
        "phpunit/phpunit": "^10.0",
        "fakerphp/faker": "^1.9.1",
        "spatie/laravel-ignition": "^2.0"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://nova.laravel.com"
        },
        {
            "type": "path",
            "url": "./nova-components/Dashboard"
        }
    ],
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "beta",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ],
        "post-update-cmd": [
            "@php artisan vendor:publish --tag=laravel-assets --ansi --force"
        ]
    }
}

I'm not sure how to go about debugging this.

Steps To Reproduce

I haven't tried reproducing in an open codebase yet, but happy to attempt it.

ahinkle commented 10 months ago

Does this happen on a fresh Laravel app with Pulse & the docker-compose project?

afoster commented 10 months ago

Hi Andy,

Not sure about that yet, but I've stripped my real codebase back and published it at https://github.com/afoster/pulse-128.

This more or less represents my app's platform and third party dependencies without most of the codebase.

Interestingly when testing it on an Intel Mac I can't immediately replicate the problem, but it can be replicated straight away on two different Apple Silicon Macs. Update: it does occur on the original app under Intel. Update: it occurs on both architectures in the demo app above

I will try a fresh Laravel app next.

afoster commented 10 months ago

Fresh Laravel install + similar Docker stack: https://github.com/afoster/pulse-128-bare

Can't replicate the problem here yet.

afoster commented 10 months ago

I've had some success disabling opcache, but I'm not sure whether this is down to my opcache settings or if there's a legitimate problem between Pulse and opcache.

afoster commented 10 months ago

I've re-enabled opcache with some saner config and it seems stable in my staging environment with no real users:

[opcache]
opcache.enable=1
opcache.jit_buffer_size=33554432
opcache.jit=tracing
opcache.revalidate_freq=5
opcache.validate_timestamps=1
opcache.memory_consumption=64
jessarcher commented 10 months ago

Interesting... what was the previous opcache config?

I can't think of anything directly in Pulse that would cause issues like this - the dashboard is pretty straightforward. I'm wondering whether it's something in Livewire (or another Pulse dependency) that's triggered the problem.

afoster commented 10 months ago

Hi Jess, so the previous opcache config was:

opcache.enable=1
opcache.enable_cli=1
opcache.jit_buffer_size=500000000
opcache.jit=1235
opcache.revalidate_freq=0
opcache.validate_timestamps=1
opcache.max_accelerated_files=10000
opcache.memory_consumption=192
opcache.max_wasted_percentage=10
opcache.interned_strings_buffer=16
opcache.fast_shutdown=1

Embarrassingly I suspect this was copypasta from some online tutorial so it wouldn't surprise me if it was rubbish. That said, it has been running OK up until now. I think like you say it'll be something to do with Pulse's dependencies or even something as simple as the fact that Pulse plus its deps adds more PHP files to the codebase and that's exceeded some watermark with opcache. Happy for you to close this if you think it's out of scope.

Thanks

timacdonald commented 10 months ago

@afoster Appreciate this. I think until we can reproduce it or nail it down to a specific thing in Pulse we will close this. Others can report if it is widespread and we can try and dig in further.