Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excimer causes memory exhaustion to trigger a segfault #828

Open
1 task
rmccue opened this issue Nov 14, 2023 · 4 comments
Open
1 task

Excimer causes memory exhaustion to trigger a segfault #828

rmccue opened this issue Nov 14, 2023 · 4 comments
Labels
bug Existing functionality isn't behaving as expected

Comments

@rmccue
Copy link
Member

rmccue commented Nov 14, 2023

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:

  • ...
@rmccue rmccue added the bug Existing functionality isn't behaving as expected label Nov 14, 2023
@rmccue
Copy link
Member Author

rmccue commented Nov 14, 2023

Confirmed I can replicate this with Excimer directly, so it's not an error in our code here:

<?php

$excimer = new ExcimerProfiler;
$excimer->start();

function foo() {
	foo();
}
foo();

@rmccue
Copy link
Member Author

rmccue commented Nov 14, 2023

FWIW, this is on humanmade/altis-local-server-php:5.0.7 - no JIT, PHP 8.0.30, Excimer 1.1.1.

@rmccue
Copy link
Member Author

rmccue commented Nov 14, 2023

Possibly related: https://phabricator.wikimedia.org/T342304

@joehoyle If you have the PHP debug symbols handy, can you gdb this to see if you can find the segfault? Assuming you also have the build tools handy for Excimer - I don't have either handy.

@rmccue
Copy link
Member Author

rmccue commented Nov 14, 2023

Filed upstream: https://phabricator.wikimedia.org/T351245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Existing functionality isn't behaving as expected
Projects
None yet
Development

No branches or pull requests

1 participant