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

PHP 7.3 segfaults when forking and using preg_match #35491

Closed
6 tasks done
ruudk opened this issue Dec 27, 2018 · 9 comments
Closed
6 tasks done

PHP 7.3 segfaults when forking and using preg_match #35491

ruudk opened this issue Dec 27, 2018 · 9 comments
Labels
outdated PR was locked due to age php PHP use is a significant feature of the PR or issue upstream issue An upstream issue report is needed

Comments

@ruudk
Copy link
Contributor

ruudk commented Dec 27, 2018

Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

  • are reporting a bug others will be able to reproduce and not asking a question or requesting software. If you're not sure or want to ask a question do so on our Discourse: https://discourse.brew.sh. To get software added or changed in Homebrew please file a Pull Request
  • have a problem with brew install (or upgrade, reinstall) a single, official formula (not cask)? If it's a general brew problem please file this issue at Homebrew/brew: https://github.com/Homebrew/brew/issues/new/choose. If it's a brew cask problem please file this issue at https://github.com/Homebrew/homebrew-cask/issues/new/choose. If it's a tap (e.g. Homebrew/homebrew-php) problem please file this issue at the tap.
  • ran brew update and can still reproduce the problem?
  • ran brew doctor, fixed all issues and can still reproduce the problem?
  • ran brew gist-logs <formula> (where <formula> is the name of the formula that failed) and included the output link? https://gist.github.com/ruudk/7eab6b140eaf616928680ac3e53b10ad
  • if brew gist-logs didn't work: ran brew config and brew doctor and included their output with your issue?

Problem

There seems to be an issue with PHP 7.3 10.14.2 (18C54) on Mojave. The issue was discovered by @bobthecow.

How to reproduce

<?php
if (preg_match('/./', 'a')) echo "pre-fork works\n";
$pid = pcntl_fork();
if ($pid == -1) {
    die('fail');
} elseif ($pid) {
    if (preg_match('/./', 'a')) echo "parent works\n";
    pcntl_wait($status);
    if (pcntl_wifsignaled($status) && pcntl_wtermsig($status) == SIGSEGV) {
        die('child process segfaulted');
    }
} else {
    if (preg_match('/./', 'a')) echo "child works\n";
}

Expected output:

pre-fork works
parent works
child works

But on Homebrew with PHP 7.3.0 on Mojave 10.14.2 (18C54) it shows:

pre-fork works
parent works
child process segfaulted

The issue does not happen on Ubuntu 16.04 + PHP 7.3 (ppa:ondre/php) for example.

@fxcoudert
Copy link
Member

Can you give us a backtrace of the segfault? Either by attaching a debugger, or looking up the macOS crash log for the process?

@fxcoudert fxcoudert added the php PHP use is a significant feature of the PR or issue label Dec 27, 2018
@ruudk
Copy link
Contributor Author

ruudk commented Dec 27, 2018

@fxcoudert Sure, you can find the crash report here

@fxcoudert
Copy link
Member

From the crash log, it appears to be the bug reported here: https://bugs.php.net/bug.php?id=77260

@ruudk
Copy link
Contributor Author

ruudk commented Dec 28, 2018

@fxcoudert It looks really the same indeed. Also this:

I did not experience this issue on production servers running Debian and PHP 7.3 from sury.

So I guess we have to wait for PHP to fix this. Do you want to close this here?

@fxcoudert fxcoudert added the upstream issue An upstream issue report is needed label Jan 3, 2019
@fxcoudert
Copy link
Member

Yes, I don't think there is much we can do here. We'll have to wait that PHP fixes this. Thanks for the bug report @ruudk!

@SMillerDev
Copy link
Member

maybe #35660 had something to do with it.

@ruudk
Copy link
Contributor Author

ruudk commented Jan 3, 2019

@SMillerDev Makes sense, can you test out the script above and see if it segfaults on your #35660 branch?

@SMillerDev
Copy link
Member

It's already merged. Doesn't seem fixed though :(

@Alexia
Copy link

Alexia commented Jan 15, 2019

Temporary workaround is to set this in your php.ini:
pcre.jit=0

@lock lock bot added the outdated PR was locked due to age label Feb 14, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Feb 14, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age php PHP use is a significant feature of the PR or issue upstream issue An upstream issue report is needed
Projects
None yet
Development

No branches or pull requests

4 participants