Skip to content

Excimer causes memory exhaustion to trigger a segfault #828

@rmccue

Description

@rmccue

Typical memory exhaustion errors are causing PHP to segfault, instead of fatal errorring. This kills the worker (and any shared memory it may be storing) and causes un-traceable user errors, significantly complicating debugging.

I also believe that this is the root cause of the problems with load-scripts.php we were seeing which we attributed to the JIT - they are actually out-of-memory issues which then become segfaults due to this bug as well as WordPress/gutenberg#54294

I've traced this down specifically to our use of Excimer, likely in X-Ray.

Minimal reproduction:

  1. Run local server the usual way
  2. Save the following into a PHP file in content/mu-plugins/:
<?php
function foo() {
    foo();
}
foo();
  1. View the site in the browser and observe it crashes with a 502 from nginx
  2. Observe composer server logs php contains a segfault

Note, if you save the same file to the root and load it directly, it fatals with the memory exhaustion

To check Excimer:

  1. Use docker exec -it -u root {id} /bin/bash to set up a root shell
  2. apt-get install procps vim - installs ps and vim
  3. vim /usr/local/etc/php/conf.d/docker-php-ext-excimer.ini - comment (#) the line which loads Excimer and save it
  4. ps aux - get the PID of PHP
  5. kill -s USR2 {pid} - reload php-fpm configuration
  6. View the site in the browser and observe it fatal errors, but from PHP rather than nginx
  7. Observe composer server logs php contains the (correct) memory exhaustion error

Acceptance criteria:

  • ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugExisting functionality isn't behaving as expected

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions