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

Error from PCRE library in PHP on startup #1682

Closed
1 task done
Danack opened this issue Nov 19, 2021 · 19 comments
Closed
1 task done

Error from PCRE library in PHP on startup #1682

Danack opened this issue Nov 19, 2021 · 19 comments

Comments

@Danack
Copy link

Danack commented Nov 19, 2021

Frequently asked questions

Errors apparently from PCRE library

I'm getting slightly odd error messages that are apparently coming from the PCRE library:

PHP Startup: ^(text/|application/xhtml\+xml) (offset=0): unrecognised compile-time option bit(s) in Unknown on line 0

To Reproduce

This can be reproduced by building and running the following docker container.

FROM debian:10-slim

USER root

# Get Debian up-to-date
RUN apt-get update -qq \
    && DEBIAN_FRONTEND=noninteractive apt-get install -y git \
    mariadb-client wget curl unzip \
    ca-certificates lsb-release apt-transport-https gnupg


# Install 3rd party PHP 8.0 packages
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee -a /etc/apt/sources.list.d/php.list

RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg

RUN  apt-get update -qq \
    && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y php8.0 php8.0-common php8.0-cli \
    php8.0-mysql php8.0-curl php8.0-xml php8.0-mbstring \
    php8.0-intl php8.0-redis php8.0-zip unzip

# Make the default directory you
WORKDIR /var/app

CMD php -v

This gives output that includes | PHP Warning: PHP Startup: ^(text/|application/xhtml\+xml) (offset=0): unrecognised compile-time option bit(s) in Unknown on line 0

Disabling mbstring makes the problem "go away", but I'm also seeing the problem with userland regexes from symfony/console.

Expected behavior

No error message.

Distribution (please complete the following information):

  • OS:debian
  • Architecture: not sure.
  • Repository: packages.sury.org

Package(s) (please complete the following information):
Output of apt-cache policy <package> works best.

Additional context
This only started happening recently, like the last few days or maybe week.

New container build that is showing this problem.

PCRE (Perl Compatible Regular Expressions) Support => enabled
PCRE Library Version => 10.32 2018-09-10
PCRE Unicode Version => 11.0.0
PCRE JIT Support => enabled
PCRE JIT Target => x86 64bit (little endian + unaligned)

Old container, built over a week ago that is not showing this problem

PCRE (Perl Compatible Regular Expressions) Support	enabled
PCRE Library Version	10.39 2021-10-29
PCRE Unicode Version	14.0.0
PCRE JIT Support	enabled
PCRE JIT Target	x86 64bit (little endian + unaligned)
@Danack Danack changed the title Error from PCRE library on Error from PCRE library in PHP on startup Nov 19, 2021
@calvera
Copy link

calvera commented Nov 19, 2021

it work if you do apt-get dist-upgrade before php installation ie...

RUN apt-get update \
 && apt-get -y install \
       apt-transport-https \
       lsb-release \
       ca-certificates \
       curl \
       wget \
       bash \
       patch \
       supervisor \
       jpegoptim \
       pngquant \
       procps \
       jq \
       zip \
 && wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg \
 && sh -c 'echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list' \
 && apt-get update \
 && apt-get dist-upgrade -y \
 && apt-get install -y \
       php8.0-fpm \
       php8.0-cli \
       php8.0-curl \
       php8.0-mbstring \
       php8.0-raphf \
       php8.0-http \
       php8.0-uuid \
       php8.0-amqp \
       php8.0-redis \
       php8.0-memcached \
       php8.0-igbinary \
       php8.0-apcu \
       php8.0-imagick \
       php8.0-yaml \
       php8.0-pgsql \
       php8.0-intl \
       php8.0-zip \
       php8.0-opcache \
       php8.0-xsl \
       php8.0-bcmath \
       php8.0-gd \
       php8.0-soap \

@Danack
Copy link
Author

Danack commented Nov 19, 2021

possibly related - https://bugs.php.net/bug.php?id=81424

@luispabon
Copy link

luispabon commented Nov 19, 2021

Affected versions:

  • 7.4.26
  • 8.0.13

Unaffected: 7.3.33

@Danack
Copy link
Author

Danack commented Nov 19, 2021

@calvera - thanks, can confirm that adding a dist-upgrade makes the issue go away.

RUN  apt-get update -qq && \
     apt-get dist-upgrade -y && \
     DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y php8.0 php8.0-common php8.0-cli \
     php8.0-mysql php8.0-curl php8.0-xml php8.0-mbstring \
     php8.0-intl php8.0-redis php8.0-zip unzip

I will let Mr Surý decide whether to close this issue or not.

@zerodeux
Copy link

I have the exact same bug with PHP-7.4 on Debian 10 when going from 7.4.25-2+020211101.54+debian101.gbp484212 to 7.4.26-1+020211119.55+debian101.gbpf9fa11, reproduced on several servers with Wordpress and Symfony-based apps, REs that did work before without warnings suddenly fail.

It seems to happen because those servers keep Debian's libpcre2 :

||/ Name               Version      Architecture Description
+++-==================-============-============-===================================================================
ii  libpcre2-8-0:amd64 10.32-5      amd64        New Perl Compatible Regular Expression Library- 8 bit runtime files

But it should upgrade to deb.sury.org's libpcre2 :

||/ Name               Version                                    Architecture Description
+++-==================-==========================================-============-===================================================================
ii  libpcre2-8-0:amd64 10.39-1+0~20211102.13+debian10~1.gbp2315ad amd64        New Perl Compatible Regular Expression Library- 8 bit runtime files

In my case it's by design, I have pinned deb.sury.org Pacakges (via /etc/apt/preferences.d) in order not to pull dependencies from this repo as a default. But it's my fault it's not working if I don't let in the compatible libpcre2 from deb.sury.org.

@luispabon
Copy link

luispabon commented Nov 19, 2021

dist-upgrade brings in newer libs, including pcre, from Ondrej's PPA, which when installed fix the problem:

Unpacking libpcre3:amd64 (2:8.44-2+ubuntu20.04.1+deb.sury.org+1) over (2:8.39-12build1) ...

Perhaps the php packages should depend on this newer version. For instance, a docker build (see below) results in a broken build, even though we're installing PHP from scratch. You typically don't run package upgrades on docker builds as they result on irreproducible builds.

FROM ubuntu:focal

ENV TERM=linux
ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
    && apt-get install -y --no-install-recommends gnupg \
    && echo "deb http://ppa.launchpad.net/ondrej/php/ubuntu focal main" > /etc/apt/sources.list.d/ondrej-php.list \
    && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C \
    && apt-get update \
    && apt-get -y --no-install-recommends install \
        ca-certificates \
        curl \
        unzip \
        php8.0-apcu \
        php8.0-cli \
        php8.0-curl \
        php8.0-mbstring \
        php8.0-opcache \
        php8.0-readline \
        php8.0-xml \
        php8.0-zip \
    && apt-get clean \
    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* ~/.composer

COPY --from=composer:2 /usr/bin/composer /usr/bin/composer

@cmb69
Copy link

cmb69 commented Nov 19, 2021

I think this is caused by php/php-src#7602, in combination with some pcre.h confusion (bundled vs. system). Not sure whether that is a distro issue or a general issue of php-src. Anyway, upstream ticket is https://bugs.php.net/bug.php?id=81640.

@rfay
Copy link

rfay commented Nov 19, 2021

I would be really appreciative if this could be solved without change to existing installations, because it breaks lots of ddev instances already in the wild. I'm happy to add the dist-upgrade to the code that generates the changes, but that won't solve the problem for existing people.

Interesting factoid: this isn't an issue on arm64, only on amd64.

Second interesting factoid: Causes a flaming crash in composer self-update (php7.4, amd64). `sudo apt-get update && sudo apt-get install php7.4-tidy, which forces several other upgrades... then

root@ba32d083e588:/# composer self-update
PHP Fatal error:  Uncaught ErrorException: preg_match_all(): Compilation failed: unrecognised compile-time option bit(s) at offset 0 in phar:///usr/local/bin/composer/vendor/symfony/console/Formatter/OutputFormatter.php:137
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'preg_match_all(...', 'phar:///usr/loc...', 137, Array)
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Formatter/OutputFormatter.php(137): preg_match_all('#<(([a-z][a-z0-...', '', NULL, 256)
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Output/Output.php(155): Symfony\Component\Console\Formatter\OutputFormatter->format('')
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Output/Output.php(132): Symfony\Component\Console\Output\Output->write(Array, true, 16)
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(641): Symfony\Component\Console\Output\Output->writeln('', 16)
#5 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(127): Symfony\Component\Console\Application in phar:///usr/local/bin/composer/vendor/symfony/console/Formatter/OutputFormatter.php on line 137

Fatal error: Uncaught ErrorException: preg_match_all(): Compilation failed: unrecognised compile-time option bit(s) at offset 0 in phar:///usr/local/bin/composer/vendor/symfony/console/Formatter/OutputFormatter.php:137
Stack trace:
#0 [internal function]: Composer\Util\ErrorHandler::handle(2, 'preg_match_all(...', 'phar:///usr/loc...', 137, Array)
#1 phar:///usr/local/bin/composer/vendor/symfony/console/Formatter/OutputFormatter.php(137): preg_match_all('#<(([a-z][a-z0-...', '', NULL, 256)
#2 phar:///usr/local/bin/composer/vendor/symfony/console/Output/Output.php(155): Symfony\Component\Console\Formatter\OutputFormatter->format('')
#3 phar:///usr/local/bin/composer/vendor/symfony/console/Output/Output.php(132): Symfony\Component\Console\Output\Output->write(Array, true, 16)
#4 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(641): Symfony\Component\Console\Output\Output->writeln('', 16)
#5 phar:///usr/local/bin/composer/vendor/symfony/console/Application.php(127): Symfony\Component\Console\Application in phar:///usr/local/bin/composer/vendor/symfony/console/Formatter/OutputFormatter.php on line 137
root@ba32d083e588:/# 

@oerdnj
Copy link
Owner

oerdnj commented Nov 19, 2021

@oerdnj I think increasing the minimum libpcre2-dev version to the latest release in the control file would be a good solution.

No, that's not going to work. The libpcre2-8-0 package is independent on the development library package.

hswong3i added a commit to alvistack/ansible-role-php that referenced this issue Nov 21, 2021
@Igor-Yavych
Copy link

On debian buster (-slim), simply running apt-get upgrade -y will suffice as it will update libpcre2-8-0 to 10.39-1 and libpcre3 to 2:8.44 from sury.org repo

@oerdnj
Copy link
Owner

oerdnj commented Nov 21, 2021

FTR installing libpcre2-dev is wrong and definitely not recommended solution. You need to actually upgrade all the packages instead of randomly installing development libraries. I am going to delete all comments that recommend installing libpcre2-dev now.

Repository owner deleted a comment from ohmydevops Nov 21, 2021
Repository owner deleted a comment from shivammathur Nov 21, 2021
Repository owner deleted a comment from peterdd Nov 21, 2021
Repository owner deleted a comment from swarrenwecareconnectorg Nov 21, 2021
@ohmydevops
Copy link

ohmydevops commented Nov 21, 2021

FTR installing libpcre2-dev is wrong and definitely not recommended solution. You need to actually upgrade all the packages instead of randomly installing development libraries. I am going to delete all comments that recommend installing libpcre2-dev now.

@oerdnj

@oerdnj
Copy link
Owner

oerdnj commented Nov 21, 2021

Is it good to write an apt-get upgrade command in Dockerfiles?

This is a bare minimum. You should be doing apt-get dist-upgrade otherwise you are running random mix of updated and outdated packages.

@miketimofeev
Copy link

This also broke GH-hosted images generation in https://github.com/actions/virtual-environments.
We have made a PR with libpcre2 upgrade as workaround to the issue actions/runner-images#4551

@oerdnj
Copy link
Owner

oerdnj commented Nov 22, 2021

I think this is caused by php/php-src#7602

Yes, see PCRE2Project/pcre2#56

in combination with some pcre.h confusion (bundled vs. system).

Nope, using different compile-time and run-time system library is all that's needed to trigger this.

Not sure whether that is a distro issue or a general issue of php-src. Anyway, upstream ticket is https://bugs.php.net/bug.php?id=81640.

I think this needs workaround at the distro level. Generally speaking, the problem lies in the fact that the newly added option is header only and not symbol, so there's no way how to track backwards compatibility. This will require some manual tweaking to the Debian packaging. I already applied the change to the DEB.SURY.ORG src:pcre2, but the same problem plagues vanilla Debian, so I already suggested a fix to Matthew Vernon, the maintainer of src:pcre2. Basically, same bump in the minimal version will be needed every time there's a change in options in the header file.

@oerdnj
Copy link
Owner

oerdnj commented Nov 22, 2021

Newly rebuilt packages should already contain libpcre2-8-0 (>= 10.38) in Depends, closing.

@rfay
Copy link

rfay commented Nov 22, 2021

This doesn't seem to have made it to Debian arm64 yet, although working on Debian amd64. Thanks for the fix, hope it will propagate everywhere soon.

@oerdnj
Copy link
Owner

oerdnj commented Nov 22, 2021

TBH I didn't wait for pcre2 to be built on all archs, so this will get fixed with the next package update.

@rfay
Copy link

rfay commented Nov 22, 2021

Thanks, and as always thanks for these packages.

Sooner package update is better because existing projects on arm64 are affected by this and there's no way to workaround that I've thought of. I did already add the dist-upgrade as standard though, so future situations wouldn't be affected by this (after next ddev release).

hswong3i added a commit to alvistack/ansible-role-php that referenced this issue Nov 23, 2021
rfay added a commit to rfay/ddev that referenced this issue Dec 6, 2021
…3385)"

This exact dist-upgrade is now breaking dbimage_extra_packages.
It's probably due to an error in mariadb packages,
but it seems that apt-get dist-upgrade is not a risk-free
action.

Also, this whole problem seems to have been solved upstream in
the deb.sury.org package.

See ddev#3385 and
oerdnj/deb.sury.org#1682

This reverts commit d385ef9.
rfay added a commit to ddev/ddev that referenced this issue Dec 6, 2021
…" (#3425)

This exact dist-upgrade is now breaking dbimage_extra_packages.
It's probably due to an error in mariadb packages,
but it seems that apt-get dist-upgrade is not a risk-free
action.

Also, this whole problem seems to have been solved upstream in
the deb.sury.org package.

See #3385 and
oerdnj/deb.sury.org#1682

This reverts commit d385ef9.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants