Bug 1434487

Summary: PCRE 8.32 mismatches Unicode ranges in JIT mode
Product: Red Hat Enterprise Linux 6 Reporter: Martin Kyral <mkyral>
Component: pcreAssignee: Petr Pisar <ppisar>
Status: CLOSED NOTABUG QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.9   
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1402288 Environment:
Last Closed: 2017-03-22 09:39:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Martin Kyral 2017-03-21 15:32:18 UTC
+++ This bug was initially created as a clone of Bug #1402288 +++
Happens on RHEL 6 with pcre-7.8-7.el6.x86_64 as well.

+++ This bug was initially created as a clone of Bug #1400267 +++

Name        : pcre-devel
Arch        : x86_64
Version     : 8.32
Release     : 15.el7_2.1
[...]
Steps to Reproduce:
1. php -r "var_dump(preg_replace('/[\\x{0000}\\x{200B}-\\x{200D}\\x{FEFF}]|\\r?\\n|\\r/u', '', 'test'));"

Actual results:
string(0) ""

Expected results:
string(4) "test"

[...]
> I can't replicate using pcretest either, but that's only half the picture as
> pcretest does not perform any replacement. The issue in my snippet
> definitely exists under PHP 7.0.13 and the system PCRE implementation (8.32).
> 
I found it. It's because of JIT. If I request pcretest to use JIT, it matches:

$ printf '%s\n%s\n' '/[\x{0000}\x{200B}-\x{200D}\x{FEFF}]|\r?\n|\r/8W' 'test' | pcretest -s++
PCRE version 8.32 2012-11-30

  re> data>  0: t (JIT)
data>

--- Additional comment from Remi Collet on 2016-12-07 04:09:26 EST ---

From PHP side, also need to have jit enabled:

# php -n -d pcre.jit=1 -r "var_dump(PHP_VERSION, preg_replace('/[\\x{0000}\\x{200B}-\\x{200D}\\x{FEFF}]|\\r?\\n|\\r/u', '', 'test'));"
string(6) "7.0.10"
string(0) ""

# php -n -d pcre.jit=0 -r "var_dump(PHP_VERSION, preg_replace('/[\\x{0000}\\x{200B}-\\x{200D}\\x{FEFF}]|\\r?\\n|\\r/u', '', 'test'));"
string(6) "7.0.10"
string(4) "test"


BTW, our build (rh-php70) have pcre.jit=0 by default (original bug report was about a non-rh package)

Comment 1 Petr Pisar 2017-03-22 09:39:35 UTC
pcre-7.8-7.el6 does not have a JIT mode.