Hello, we hit the same crash on trixie (e2guardian 5.5.8-1, libpcre2-posix3 10.46-1~deb13u3, libc6 2.41-12+deb13u5, amd64) since the upgrade from bookworm (5.3.5-4+deb12u1, built against pcre3). In production it segfaults 7 to 79 times per working day; with systemd restarting it, clients see short "Connection refused" windows.
Root cause ---------- debian/patches/1003_pcre2.patch only switches the build from pcreposix.h to pcre2posix.h, and debian/rules keeps --enable-pcre=yes. The PCRE2 POSIX wrapper is documented as not thread-safe (pcre2posix(3): "The functions described here are NOT thread-safe, and should not be used in multi-threaded applications"). pcre2_regcomp() allocates a single match_data block inside regex_t, and every pcre2_regexec() call on that regex_t reuses it (src/pcre2posix.c: "md = preg->re_match_data"). e2guardian compiles its regexp lists once and matches them from all worker threads concurrently (httpworkers), so threads overwrite each other's ovector. RegExp::match() (src/RegExp.cpp) then advances "pos += largestoffset" using the foreign offsets and calls regexec(®, pos, ..., REG_NOTBOL) / strncpy(submatch, pos + rm_so, ...) past the end of the subject. That is the segfault in libc: the crashing instructions are the EVEX strlen (called by pcre2_regexec() for the subject length) and the EVEX strcpy/strncpy family. A core dump from our crash shows frame #0 in libc.so.6 (strlen) and frame #1 in libpcre2-posix.so.3.0.6 (pcre2_regexec), with an invalid subject pointer. Reproduction ------------ debian:trixie container, stock 5.5.8-1, a trivial HTTP backend on the configured proxyport, and ~300 concurrent client threads sending plain HTTP requests (keep-alive, search-engine URLs, so the default searchregexplist and other regexp lists are evaluated): - 5.5.8-1 as packaged: SIGSEGV (exit 139) after about 4 seconds - same load with a single client thread: no crash (needs concurrency) - 5.5.8-1 rebuilt with --enable-pcre=no (glibc regcomp/regexec): 3 x 60 s, ~780k requests, no crash - 5.5.8-1 as packaged, all *regexp* lists emptied: 3 x 60 s, no crash Suggested fix ------------- Either build with --enable-pcre=no (glibc regex is thread-safe; upstream changed the default to no on the v5.5 branch), or move to the native PCRE2 API that upstream added on the v5.5 branch (commit 9259aa4, "PCRE2 support added & fix for #890"), which does not use the POSIX wrapper. A trixie-pu would be very welcome, as the package is close to unusable under load in stable. Workaround for affected users: comment out all entries in the *regexp* lists (searchregexplist, browserregexplist, *regexpurllist, ...) or rebuild with --enable-pcre=no. Given the impact (repeated crashes of a network service under normal load), it may be worth raising the severity to important. Regards, Jan Sklenar

