[Bug 275522] www/mod_php81: Apache crashes on reload after switch to system pcre

From: <bugzilla-noreply_at_freebsd.org>
Date: Mon, 04 Dec 2023 10:26:40 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=275522

            Bug ID: 275522
           Summary: www/mod_php81: Apache crashes on reload after switch
                    to system pcre
           Product: Ports & Packages
           Version: Latest
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: Individual Port(s)
          Assignee: bofh@freebsd.org
          Reporter: majo-bugs.freebsd.org@cerny.sk
          Assignee: bofh@freebsd.org
             Flags: maintainer-feedback?(bofh@freebsd.org)

The change "lang/php81: Update version 8.1.25=>8.1.26"
https://cgit.freebsd.org/ports/commit/?id=06be0d5391f475771145a7a9d68d34b0ad5a9b85
is causing apache with mod_php and a bunch of php extensions to crash on reload
(apachectl graceful or signal 30 - SIGUSR1)

It crashes reliably on apachectl reload with extensions1 (see comments) with
the following back trace:

(lldb) target create "httpd" --core "httpd-9988.core"
Core file '/tmp/httpd-9988.core' (x86_64) was loaded.
(lldb) bt
* thread #1, name = 'httpd', stop reason = signal SIGSEGV
  * frame #0: 0x000000080141a5d4 libzstd.so.1`___lldb_unnamed_symbol756 + 740
    frame #1: 0x00000008027ce1c6
libphp.so`zend_extension_startup(extension=0x0000000801b18510) at
zend_extensions.c:196:7
    frame #2: 0x00000008027b0ba1
libphp.so`zend_llist_apply_with_del(l=0x0000000802954100,
func=(libphp.so`zend_extension_startup at zend_extensions.c:193)) at
zend_llist.c:171:7
    frame #3: 0x00000008027ce1a8 libphp.so`zend_startup_extensions at
zend_extensions.c:217:2 [artificial]
    frame #4: 0x000000080274f8c7 libphp.so`php_module_startup(sf=<unavailable>,
additional_modules=<unavailable>, num_additional_modules=1) at main.c:2263:2
    frame #5: 0x00000008028ad385
libphp.so`php_apache2_startup(sapi_module=<unavailable>) at
sapi_apache2.c:381:6
    frame #6: 0x00000008028acbd6
libphp.so`php_apache_server_startup(pconf=0x0000000800907028,
plog=<unavailable>, ptemp=<unavailable>, s=<unavailable>) at
sapi_apache2.c:495:6
    frame #7: 0x0000000000263d6f httpd`ap_run_post_config + 79
    frame #8: 0x000000000025f4cc httpd`main + 2476
    frame #9: 0x000000000025e910 httpd`_start + 256

It crashes sporadically on another server with different set of extensions2
(see comments) with the following back trace:

(lldb) target create "httpd" --core "httpd-99468.core"
Core file '/tmp/httpd-99468.core' (x86_64) was loaded.
(lldb) bt
* thread #1, name = 'httpd', stop reason = signal SIGSEGV
  * frame #0: 0x00000008020f5124 libphp.so`zend_get_callable_name_ex + 164
    frame #1: 0x00000008020f9f06 libphp.so`___lldb_unnamed_symbol7929 + 22
    frame #2: 0x00000008020dc5d1 libphp.so`zend_llist_apply_with_del + 81
    frame #3: 0x000000080207b107 libphp.so`php_module_startup + 2359
    frame #4: 0x00000008021da2c5 libphp.so`___lldb_unnamed_symbol9598 + 21
    frame #5: 0x00000008021d9aa6 libphp.so`___lldb_unnamed_symbol9593 + 118
    frame #6: 0x00000000002627cf httpd`ap_run_post_config + 79
    frame #7: 0x000000000025de8c httpd`main + 2476
    frame #8: 0x000000000025d2d0 httpd`_start + 256

When I revert external-pcre (the following "lines") from the Makefile:

BUILD_DEPENDS=  re2c>0:devel/re2c
CONFIGURE_ARGS+= --with-external-pcre=${LOCALBASE}

and revert pkg-plist so that include/php/ext/pcre/pcre2lib/ header files are
installed, the crash on reload does not happen.

See also my bug report to PHP project, where I originally thought it is a bug
of PHP 8.1.26:
mod_php 8.1.26 crashes on apache graceful restart
https://github.com/php/php-src/issues/12844

Note the following comment by nielsdos (PHP contributor):
> If I had to take a guess, one possibility is that a conflicting version of pcre2 is used. e.g. when one (transitive) library dependency of an extension depends on pcre2 and php also uses pcre2 for ext/pcre, this can cause problems when different versions are used because of conflicting symbols.
> Using the bundled pcre2 would fix this because we prefix some symbol names with the name php to avoid that exact issue.

-- 
You are receiving this mail because:
You are the assignee for the bug.