php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #75223 PCRE JIT broken in 7.2
Submitted: 2017-09-18 11:58 UTC Modified: 2017-09-18 20:42 UTC
From: giovanni at giacobbi dot net Assigned: cmb (profile)
Status: Closed Package: PCRE related
PHP Version: 7.2.0RC2 OS: Linux CentOS 7.4.1708
Private report: No CVE-ID: None
 [2017-09-18 11:58 UTC] giovanni at giacobbi dot net
Description:
------------
There is a problem in preg_match() when JIT is enabled and 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 \
  --disable-cgi \
  --enable-intl \
  --with-layout=GNU \
  --enable-maintainer-zts \
  --with-gettext=static \
  --with-iconv \
  --with-mysqli=mysqlnd \
  --enable-exif \
  --with-openssl \
  --with-curl


Test script:
---------------
var_dump(preg_match('/^a/', "a"));
var_dump(preg_match('/a/', "a"));


Expected result:
----------------
int(1)
int(1)

Actual result:
--------------
int(0)
segmentation fault

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-09-18 12:14 UTC] danack@php.net
Please provide a backtrace.
 [2017-09-18 13:45 UTC] remi@php.net
Sorry, I cannot reproduce.

$ php72 -n -i | grep PCRE
PCRE (Perl Compatible Regular Expressions) Support => enabled
PCRE Library Version => 8.41 2017-07-05
PCRE JIT Support => enabled

$ php72 -n  foo.php 
int(1)
int(1)
 [2017-09-18 14:05 UTC] levim@php.net
Remi, just to be sure: did you test it with Apache2 with event MPM? According to the reporter it does not occur with the command line, only with the Apache2 with event MPM SAPI.
 [2017-09-18 14:53 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2017-09-18 14:53 UTC] cmb@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.
 [2017-09-18 18:36 UTC] giovanni at giacobbi dot net
-Status: Feedback +Status: Closed
 [2017-09-18 18:36 UTC] giovanni at giacobbi dot net
I can confirm that the following fixes the issue:
https://github.com/php/php-src/commit/5ef10d08ec2d0823fb21ad189dacfb43d900a0b5
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sun Nov 19 01:31:42 2017 UTC