php extension_crash ai_generated true

Segmentation fault (core dumped) in /usr/lib/php/20230831/some_extension.so

ID: php/segfault-extension

Also available as: JSON · Markdown
75%Fix Rate
80%Confidence
40Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
83 active

Root Cause

Segmentation faults in PHP are caused by bugs in C-level extensions, incompatible extension versions, or memory corruption. The PHP process crashes without a PHP-level error message, making these difficult to diagnose. Common culprits include outdated PECL extensions, Xdebug, and database driver extensions compiled against a different PHP version.

generic

Workarounds

  1. 82% success Enable core dumps and use GDB to identify the crashing extension
    Enable core dumps: 'ulimit -c unlimited' and set 'rlimit_core = unlimited' in php-fpm.conf. Reproduce the crash. Analyze with GDB: 'gdb php core.12345' then 'bt' for backtrace. The backtrace will show which .so extension caused the crash. Update or remove that extension.
  2. 78% success Disable extensions one by one to isolate the culprit, then update or replace it
    List loaded extensions with 'php -m'. Disable extensions one at a time by commenting them out in the relevant .ini file in /etc/php/8.3/mods-available/ or using 'phpdismod'. Test after each change. Once the crashing extension is identified, update it with 'pecl upgrade {extension}' or replace it with a compatible alternative.

Dead Ends

Common approaches that don't work:

  1. Ignoring the segfault and relying on PHP-FPM to restart the worker 80% fail

    While PHP-FPM does restart crashed workers, repeated segfaults cause service instability, lost requests, and potential data corruption if the crash occurs mid-transaction. Each crash also loses any in-flight request data. Monitoring may not detect the issue if restarts are fast.

  2. Reinstalling PHP without identifying the problematic extension 75% fail

    Reinstalling PHP without removing or updating the offending extension will reproduce the same segfault. The crash originates in the extension's shared object (.so) file, not in PHP core. A fresh PHP install loads the same broken extension.

Error Chain

Leads to:
Preceded by:
Frequently confused with: