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
ruudk opened this issue Dec 27, 2018 · 9 comments
Closed

PHP 7.3 segfaults when forking and using preg_match #35491

ruudk opened this issue Dec 27, 2018 · 9 comments

Comments

@ruudk
Copy link
Contributor

@ruudk 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

  • brew install php@7.3
  • Create test.php with the following contents:
<?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";
}
  • Run it with /usr/local/opt/php@7.3/bin/php test.php

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

This comment has been minimized.

Copy link
Member

@fxcoudert fxcoudert commented Dec 27, 2018

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 label Dec 27, 2018
@ruudk

This comment has been minimized.

Copy link
Contributor Author

@ruudk ruudk commented Dec 27, 2018

@fxcoudert Sure, you can find the crash report here

@fxcoudert

This comment has been minimized.

Copy link
Member

@fxcoudert fxcoudert commented Dec 27, 2018

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

@ruudk

This comment has been minimized.

Copy link
Contributor Author

@ruudk 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

This comment has been minimized.

Copy link
Member

@fxcoudert fxcoudert commented Jan 3, 2019

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!

@fxcoudert fxcoudert closed this Jan 3, 2019
@SMillerDev

This comment has been minimized.

Copy link
Member

@SMillerDev SMillerDev commented Jan 3, 2019

maybe #35660 had something to do with it.

@ruudk

This comment has been minimized.

Copy link
Contributor Author

@ruudk 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

This comment has been minimized.

Copy link
Member

@SMillerDev SMillerDev commented Jan 3, 2019

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

@Alexia

This comment has been minimized.

Copy link

@Alexia Alexia commented Jan 15, 2019

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

@lock lock bot added the outdated 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.
Projects
None yet
4 participants
You can’t perform that action at this time.