PCRE JIT broken in PHP 7.2

php.internals

Giovanni Giacobbi

8 years ago
Greetings, just an heads up, I started testing my project with PHP 7.2.0RC2 but it was causing a segmentation fault. I tracked down the problem to preg_match(), in particular when JIT is enabled and ONLY when running through Apache2 with event MPM. This problem does not occur with command line invocation. Here are the versions I tested, same environment: 7.1.9 works with PCRE JIT enabled 7.2.0alpha1 broken 7.2.0rc2 broken Build command line: ./configure \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-fpm-user=httpd \ --with-fpm-group=httpd \ --disable-cgi \ --enable-intl \ --with-layout=GNU \ --enable-maintainer-zts \ --with-gettext=static \ --with-iconv \ --with-mysqli=mysqlnd \ --enable-exif \ --with-openssl \ --with-curl The effect i observed is the following: var_dump(preg_match('/^a/', "a")); => int(0) var_dump(preg_match('/a/', "a")); => segmentation fault If you need any further information let me know. Kind regards
-- Giovanni Giacobbi

Dan Ackroyd

8 years ago
On 18 September 2017 at 12:28, Giovanni Giacobbi <giovanni@giacobbi.net> wrote:
> > just an heads up, I started testing my project with PHP 7.2.0RC2 but it was > causing a segmentation fault.
Even if you think bugs are urgent enough to email the internals list - please open a bug report at bugs.php.net first, so that people can response to it without spamming the list.
> If you need any further information let me know.
"See how to get a backtrace in case of a crash": https://bugs.php.net/bugs-generating-backtrace.php cheers Dan Ack

Giovanni Giacobbi

8 years ago
On 18 September 2017 at 13:46, Dan Ackroyd <danack@basereality.com> wrote:
> On 18 September 2017 at 12:28, Giovanni Giacobbi <giovanni@giacobbi.net> > wrote: > > > > just an heads up, I started testing my project with PHP 7.2.0RC2 but it > was > > causing a segmentation fault. > > Even if you think bugs are urgent enough to email the internals list - > please open a bug report at bugs.php.net first, so that people can > response to it without spamming the list. > >
The attitude in this ml is always very challenging. Yes, a bug that completely brokens a working environment when upgrading from 7.1.9 to 7.2.0, while we are in RC2 stage, I think it's quite urgent and requires attention. Anyway, the bug has been filed as #75223
> If you need any further information let me know. > > "See how to get a backtrace in case of a crash": > https://bugs.php.net/bugs-generating-backtrace.php > >
I believe who worked on the PCRE support (the problem is either the bundled pcre library update or the JIT fast path API), might have enough information, otherwise if they kindly request the backtrace I will provide it. Of course I'm also fine sticking with 7.1.9 and waiting for someone else to incur in the problem and wait until it's fixed.
-- Giovanni Giacobbi

Rowan Collins

8 years ago
On 18 September 2017 13:05:53 BST, Giovanni Giacobbi <giovanni@giacobbi.net> wrote:
>On 18 September 2017 at 13:46, Dan Ackroyd <danack@basereality.com> >wrote: >> Even if you think bugs are urgent enough to email the internals list >- >> please open a bug report at bugs.php.net first, so that people can >> response to it without spamming the list. >> >> >The attitude in this ml is always very challenging. > >Yes, a bug that completely brokens a working environment when upgrading >from 7.1.9 to 7.2.0, while we are in RC2 stage, I think it's quite >urgent >and requires attention. > >Anyway, the bug has been filed as #75223
Hi Giovanni, I don't think Dan was saying that this was not urgent, just pointing out the best way to combine the two venues: if you file the bug first, you can write to the list saying "I think bug XYZ is critical and needs more attention, please see the details on the bug tracker". I can see how it could be read as a criticism, but I don't think that was the intention. Thanks for taking the time to bring this to people's attention, hopefully somebody in the know will be able to look at the bug and track it down. Cheers,
-- Rowan Collins [IMSoP]

Dmitry Stogov

8 years ago
The problem may be caused by "incorrect" dynamic linking to different libpcre instances. e.g one libbcre is use by Apache or some Apache module and another is embedded into PHP. The backtrace would be useful, to prove this guess. Thanks. Dmitry. ________________________________ From: giovanni.g@gmail.com <giovanni.g@gmail.com> on behalf of Giovanni Giacobbi <giovanni@giacobbi.net> Sent: Monday, September 18, 2017 2:28:35 PM To: PHP Internals List Subject: [PHP-DEV] PCRE JIT broken in PHP 7.2 Greetings, just an heads up, I started testing my project with PHP 7.2.0RC2 but it was causing a segmentation fault. I tracked down the problem to preg_match(), in particular when JIT is enabled and ONLY when running through Apache2 with event MPM. This problem does not occur with command line invocation. Here are the versions I tested, same environment: 7.1.9 works with PCRE JIT enabled 7.2.0alpha1 broken 7.2.0rc2 broken Build command line: ./configure \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-fpm-user=httpd \ --with-fpm-group=httpd \ --disable-cgi \ --enable-intl \ --with-layout=GNU \ --enable-maintainer-zts \ --with-gettext=static \ --with-iconv \ --with-mysqli=mysqlnd \ --enable-exif \ --with-openssl \ --with-curl The effect i observed is the following: var_dump(preg_match('/^a/', "a")); => int(0) var_dump(preg_match('/a/', "a")); => segmentation fault If you need any further information let me know. Kind regards
-- Giovanni Giacobbi

Dmitry Stogov

8 years ago
This commit should fix the problem https://github.com/php/php-src/commit/5ef10d08ec2d0823fb21ad189dacfb43d900a0b5 Thanks. Dmitry. ________________________________ From: Dmitry Stogov <dmitry@zend.com> Sent: Monday, September 18, 2017 7:29:24 PM To: Giovanni Giacobbi; PHP Internals List Subject: Re: [PHP-DEV] PCRE JIT broken in PHP 7.2 [This sender failed our fraud detection checks and may not be who they appear to be. Learn about spoofing at http://aka.ms/LearnAboutSpoofing] The problem may be caused by "incorrect" dynamic linking to different libpcre instances. e.g one libbcre is use by Apache or some Apache module and another is embedded into PHP. The backtrace would be useful, to prove this guess. Thanks. Dmitry. ________________________________ From: giovanni.g@gmail.com <giovanni.g@gmail.com> on behalf of Giovanni Giacobbi <giovanni@giacobbi.net> Sent: Monday, September 18, 2017 2:28:35 PM To: PHP Internals List Subject: [PHP-DEV] PCRE JIT broken in PHP 7.2 Greetings, just an heads up, I started testing my project with PHP 7.2.0RC2 but it was causing a segmentation fault. I tracked down the problem to preg_match(), in particular when JIT is enabled and ONLY when running through Apache2 with event MPM. This problem does not occur with command line invocation. Here are the versions I tested, same environment: 7.1.9 works with PCRE JIT enabled 7.2.0alpha1 broken 7.2.0rc2 broken Build command line: ./configure \ --with-apxs2=/usr/local/apache2/bin/apxs \ --with-fpm-user=httpd \ --with-fpm-group=httpd \ --disable-cgi \ --enable-intl \ --with-layout=GNU \ --enable-maintainer-zts \ --with-gettext=static \ --with-iconv \ --with-mysqli=mysqlnd \ --enable-exif \ --with-openssl \ --with-curl The effect i observed is the following: var_dump(preg_match('/^a/', "a")); => int(0) var_dump(preg_match('/a/', "a")); => segmentation fault If you need any further information let me know. Kind regards
-- Giovanni Giacobbi

Giovanni Giacobbi

8 years ago
On 18 September 2017 at 19:04, Dmitry Stogov <dmitry@zend.com> wrote:
> This commit should fix the problem https://github.com/php/php-src/commit/ > 5ef10d08ec2d0823fb21ad189dacfb43d900a0b5 > > > Yes! I tested 7.2.0RC2 with this patch applied and it fixes the problem.
Thank you!