docker-library / php

Docker Official Image packaging for PHP
https://php.net
MIT License
3.81k stars 2k forks source link

Use bundled pcrelib instead of system library #495

Closed pat-bateman closed 6 years ago

pat-bateman commented 6 years ago

Debian Jessie provides libpcre3-2:8.35-3.3+deb8u4, which is older than the currently bundled versions in PHP 5.6, 7.0, and 7.1, which is 8.38.

There is the following comment in the Dockerfile-debian.template: # bundled pcre is too old for s390x (which isn't exactly a good sign) I do not know if this still applies, but pcre-8.35 provides serious trouble, e.g. with Typo3-8.

I would like suggest to remove the lines 11, 129-133 from .Dockerfile-debian.template.

yosifkit commented 6 years ago

It still fails on s390x. Most likely the comment is wrong about it being too old, but the line is correct that the bundled prce does not build on s390x.

In file included from /usr/src/php/ext/pcre/pcrelib/pcre_jit_compile.c:62:0:
/usr/src/php/ext/pcre/pcrelib/sljit/sljitLir.c:1718:49: error: conflicting types for 'sljit_create_compiler'
 SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
                                                 ^
In file included from /usr/src/php/ext/pcre/pcrelib/sljit/sljitLir.c:27:0,
                 from /usr/src/php/ext/pcre/pcrelib/pcre_jit_compile.c:62:
/usr/src/php/ext/pcre/pcrelib/sljit/sljitLir.h:420:49: note: previous declaration of 'sljit_create_compiler' was here
 SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void *allocator_data);
                                                 ^
/usr/src/php/ext/pcre/pcrelib/pcre_jit_compile.c:65:2: error: #error Unsupported architecture
 #error Unsupported architecture
  ^
/usr/src/php/ext/pcre/pcrelib/pcre_jit_compile.c: In function '_pcre_jit_compile':
/usr/src/php/ext/pcre/pcrelib/pcre_jit_compile.c:10012:12: error: too many arguments to function 'sljit_create_compiler'
 compiler = sljit_create_compiler(NULL);
            ^
In file included from /usr/src/php/ext/pcre/pcrelib/pcre_jit_compile.c:62:0:
/usr/src/php/ext/pcre/pcrelib/sljit/sljitLir.c:1718:49: note: declared here
 SLJIT_API_FUNC_ATTRIBUTE struct sljit_compiler* sljit_create_compiler(void)
                                                 ^
In file included from /usr/src/php/ext/pcre/pcrelib/sljit/sljitLir.c:27:0,
                 from /usr/src/php/ext/pcre/pcrelib/pcre_jit_compile.c:62:
/usr/src/php/ext/pcre/pcrelib/pcre_jit_compile.c: At top level:
/usr/src/php/ext/pcre/pcrelib/sljit/sljitLir.h:438:31: warning: 'sljit_set_compiler_memory_error' used but never defined
 SLJIT_API_FUNC_ATTRIBUTE void sljit_set_compiler_memory_error(struct sljit_compiler *compiler);
                               ^
/bin/bash /usr/src/php/libtool --silent --preserve-dup-deps --mode=compile cc -DHAVE_CONFIG_H -I/usr/src/php/ext/pcre/pcrelib -Iext/pcre/ -I/usr/src/php/ext/pcre/ -DPHP_ATOM_INC -I/usr/src/php/include -I/usr/src/php/main -I/usr/src/php -I/usr/src/php/ext/date/lib -I/usr/src/php/ext/ereg/regex -I/usr/include/libxml2 -I/usr/src/php/ext/mbstring/oniguruma -I/usr/src/php/ext/mbstring/libmbfl -I/usr/src/php/ext/mbstring/libmbfl/mbfl -I/usr/src/php/ext/sqlite3/libsqlite -I/usr/src/php/TSRM -I/usr/src/php/Zend  -fstack-protector-strong -fpic -fpie -O2  -I/usr/include -fstack-protector-strong -fpic -fpie -O2 -fvisibility=hidden  -c /usr/src/php/ext/pcre/php_pcre.c -o ext/pcre/php_pcre.lo 
Makefile:544: recipe for target 'ext/pcre/pcrelib/pcre_jit_compile.lo' failed
make: *** [ext/pcre/pcrelib/pcre_jit_compile.lo] Error 1

Can you elaborate on the "provides serious trouble with Typo3-8"?

pat-bateman commented 6 years ago

Sure:

After installing a fresh and current Typo3 v8 LTS version 8.7.6 (haven´t tried the new release 8.7.7 from yesterday, but former versions also showed this behavior) the php thread aborts with the following error msg:

WARNING: [pool www] child 6 said into stderr: "*** Error in `php-fpm: pool www': munmap_chunk(): invalid pointer: 0x000055fca6698cc0 ***"
WARNING: [pool www] child 6 exited on signal 6 (SIGABRT) after 82.992539 seconds from start
NOTICE: [pool www] child 18 started

A Google Search provided this result: https://github.com/oerdnj/deb.sury.org/issues/353

After manual switch to the bundled pcrelib version 8.38 in the Dockerfile php:7.1-fpm and rebuilding the image, everything works fine.

How about generally switching to the bundled pcrelib version and implement am exception for s390x?

yosifkit commented 6 years ago

I really don't want to splinter how the image works on different architectures. Without heavy debugging to patch the bundled pcrelib source, it might make more sense to migrate all the php images to Debian Stretch in order to get newer system libraries like pcre.

pat-bateman commented 6 years ago

Totally agree with you. There is also a solution with package pinning (see #457), but the most forward-looking solution will probably be the migration to Debian Stretch.

ghost commented 6 years ago

According to the pcere-jit manpage I was able to find the only supported architectures via auto-config are:

AVAILABILITY OF JIT SUPPORT

JIT support is an optional feature of PCRE. The "configure" option --enable-jit (or equivalent CMake option) must be set when PCRE is built if you want to use JIT. The support is limited to the following hardware platforms:

ARM v5, v7, and Thumb2 Intel x86 32-bit and 64-bit MIPS 32-bit Power PC 32-bit and 64-bit SPARC 32-bit (experimental)

Suggest --without-pcre-jit as a build flag instead of --with-pcre-regex=/usr , since jit was turned on by default in the newer versions so you'll get the up-to-date included version (albeit without jit support). It will likely remove problems building on s390x as well, I don't think the normal one is platform-limited.