# PCRE JIT broken in PHP 7.2

- Thread: https://externals.io/message/100697
- Original archive: https://news-web.php.net/php.internals/100697
- Started by Giovanni Giacobbi on 2017-09-18T11:28:35+00:00
- Messages: 7
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #100697 — Giovanni Giacobbi — 2017-09-18T11:28:35+00:00

URL: https://externals.io/message/100697#100697

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

---

## #100698 — Dan Ackroyd — 2017-09-18T11:46:25+00:00

URL: https://externals.io/message/100697#100698 · In reply to: #100697

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

---

## #100699 — Giovanni Giacobbi — 2017-09-18T12:05:53+00:00

URL: https://externals.io/message/100697#100699 · In reply to: #100698

> On 18 September 2017 at 12:28, Giovanni Giacobbi <giovanni@giacobbi.net>
> wrote:
> > […]
> was
> > […]
>
> 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

---

## #100700 — Rowan Collins — 2017-09-18T13:36:15+00:00

URL: https://externals.io/message/100697#100700 · In reply to: #100699

>On 18 September 2017 at 13:46, Dan Ackroyd <danack@basereality.com>
>wrote:
> > […]
>-
> > […]
>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]

---

## #100701 — Dmitry Stogov — 2017-09-18T16:29:24+00:00

URL: https://externals.io/message/100697#100701 · In reply to: #100697

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.

---

## #100702 — Dmitry Stogov — 2017-09-18T17:04:12+00:00

URL: https://externals.io/message/100697#100702

This commit should fix the problem https://github.com/php/php-src/commit/5ef10d08ec2d0823fb21ad189dacfb43d900a0b5


Thanks. Dmitry.

---

## #100703 — Giovanni Giacobbi — 2017-09-18T18:36:38+00:00

URL: https://externals.io/message/100697#100703 · In reply to: #100702

> 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!
