rspamd: segfault since alpine 3.11
Hi, I use rspamd in a docker image and upgraded it from alpine 3.10 to 3.11 and rspamd segfault at startup
Here's how to reproduce the bug:
$ cat << EOF > Dockerfile
FROM alpine:3.11
RUN apk add --no-cache rspamd rspamd-dbg gdb
RUN echo -e 'filename = "/dev/stdout";' > /etc/rspamd/local.d/logging.inc
USER rspamd
CMD ["gdb", "-ex", "run --no-fork", "-ex", "bt", "-ex", "quit", "rspamd"]
EOF
$ docker build -t rspamd .
Sending build context to Docker daemon 2.048kB
Step 1/5 : FROM alpine:3.11
---> c85b8f829d1f
Step 2/5 : RUN apk add --no-cache rspamd rspamd-dbg gdb
---> Running in 2c003d8d4070
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
(1/26) Installing expat (2.2.9-r0)
(2/26) Installing libgcc (9.2.0-r3)
(3/26) Installing ncurses-terminfo-base (6.1_p20191130-r0)
(4/26) Installing ncurses-terminfo (6.1_p20191130-r0)
(5/26) Installing ncurses-libs (6.1_p20191130-r0)
(6/26) Installing libbz2 (1.0.8-r1)
(7/26) Installing libffi (3.2.1-r6)
(8/26) Installing gdbm (1.13-r1)
(9/26) Installing xz-libs (5.2.4-r0)
(10/26) Installing readline (8.0.1-r0)
(11/26) Installing sqlite-libs (3.30.1-r1)
(12/26) Installing python3 (3.8.0-r0)
(13/26) Installing libstdc++ (9.2.0-r3)
(14/26) Installing gdb (8.3.1-r3)
(15/26) Installing libevent (2.1.11-r0)
(16/26) Installing libintl (0.20.1-r2)
(17/26) Installing libblkid (2.34-r1)
(18/26) Installing libmount (2.34-r1)
(19/26) Installing pcre (8.43-r0)
(20/26) Installing glib (2.62.3-r0)
(21/26) Installing icu-libs (64.2-r0)
(22/26) Installing luajit (2.1.0_beta3-r5)
(23/26) Installing libmagic (5.37-r1)
(24/26) Installing pcre2 (10.34-r0)
(25/26) Installing rspamd (1.9.4-r1)
Executing rspamd-1.9.4-r1.pre-install
(26/26) Installing rspamd-dbg (1.9.4-r1)
Executing busybox-1.31.1-r8.trigger
OK: 164 MiB in 40 packages
Removing intermediate container 2c003d8d4070
---> ba61febfc899
Step 3/5 : RUN echo -e 'filename = "/dev/stdout";' > /etc/rspamd/local.d/logging.inc
---> Running in 2727adc4df8f
Removing intermediate container 2727adc4df8f
---> 1c3c82e6f076
Step 4/5 : USER rspamd
---> Running in 04ddcff75f3e
Removing intermediate container 04ddcff75f3e
---> e406a379746a
Step 5/5 : CMD ["gdb", "-ex", "run --no-fork", "-ex", "bt", "-ex", "quit", "rspamd"]
---> Running in 3289c8e3c672
Removing intermediate container 3289c8e3c672
---> 1bb346ded362
Successfully built 1bb346ded362
Successfully tagged rspamd:latest
$ docker run --rm -it rspamd
GNU gdb (GDB) 8.3.1
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from rspamd...
Reading symbols from /usr/lib/debug//usr/sbin/rspamd.debug...
Starting program: /usr/sbin/rspamd --no-fork
warning: Error disabling address space randomization: Operation not permitted
2019-12-21 13:35:46 #7(main) lua; lua_cfg_transform.lua:160: group excessqp has no symbols
2019-12-21 13:35:46 #7(main) lua; lua_cfg_transform.lua:160: group excessb64 has no symbols
2019-12-21 13:35:46 #7(main) cfg; rspamd_rcl_maybe_apply_lua_transform: configuration has been transformed in Lua
2019-12-21 13:35:46 #7(main) <a9oj6b>; cfg; rspamd_config_set_action_score: action add header has been already registered with priority 0, override it with new priority: 0, old score: nan
2019-12-21 13:35:46 #7(main) <a9oj6b>; cfg; rspamd_config_set_action_score: action greylist has been already registered with priority 0, override it with new priority: 0, old score: nan
2019-12-21 13:35:46 #7(main) <a9oj6b>; cfg; rspamd_config_set_action_score: action reject has been already registered with priority 0, override it with new priority: 0, old score: nan
2019-12-21 13:35:46 #7(main) rspamd_regexp_library_init: pcre2 is compiled with JIT for x86 64bit (little endian + unaligned)
2019-12-21 13:35:46 #7(main) <a9oj6b>; cfg; rspamd_language_detector_init: loaded 46 languages, 33122 trigramms
2019-12-21 13:35:46 #7(main) <a9oj6b>; cfg; chartable_module_config: init internal chartable module
2019-12-21 13:35:46 #7(main) <a9oj6b>; cfg; dkim_module_config: init internal dkim module
2019-12-21 13:35:46 #7(main) <a9oj6b>; cfg; spf_module_config: init internal spf module
2019-12-21 13:35:46 #7(main) <a9oj6b>; cfg; rspamd_map_parse_backend: map '/var/lib/rspamd/2tld.inc.local' is not found, but it can be loaded automatically later
2019-12-21 13:35:46 #7(main) <a9oj6b>; cfg; rspamd_map_parse_backend: map '/var/lib/rspamd/surbl-whitelist.inc.local' is not found, but it can be loaded automatically later
2019-12-21 13:35:46 #7(main) <a9oj6b>; cfg; surbl_module_config: init internal surbls module, 16 uribl rules loaded
Program received signal SIGSEGV, Segmentation fault.
0x00007fcdc4e13254 in pcre2_jit_compile_8 () from /usr/lib/libpcre2-8.so.0
#0 0x00007fcdc4e13254 in pcre2_jit_compile_8 () from /usr/lib/libpcre2-8.so.0
#1 0x00007fcdc5211a9c in rspamd_regexp_post_process (r=0x562705cc4f40)
--Type <RET> for more, q to quit, c to continue without paging--
at /home/buildozer/aports/community/rspamd/src/rspamd-1.9.4/src/libutil/regexp.c:190
#2 rspamd_regexp_new (pattern=<optimized out>, flags=0x562705cc4860 "u",
err=err@entry=0x7ffec05254e0)
at /home/buildozer/aports/community/rspamd/src/rspamd-1.9.4/src/libutil/regexp.c:481
#3 0x00007fcdc5299aee in rspamd_mime_expr_parse_regexp_atom (
cfg=<optimized out>, line=0x7fcdc2c7a920 "/[$€$¢¥₽]/Hu",
pool=0x7fcdc56c1f00)
at /home/buildozer/aports/community/rspamd/src/rspamd-1.9.4/src/libmime/mime_expressions.c:494
#4 rspamd_mime_expr_parse (line=<optimized out>, len=<optimized out>,
pool=0x7fcdc56c1f00, ud=<optimized out>, err=0x7ffec0525600)
at /home/buildozer/aports/community/rspamd/src/rspamd-1.9.4/src/libmime/mime_expressions.c:799
#5 0x00007fcdc51fb991 in rspamd_parse_expression (line=<optimized out>,
line@entry=0x5627056039c0 "Subject=/[$€$¢¥₽]/Hu",
len=<optimized out>, len@entry=0, subr=0x7fcdc53f4fa0 <mime_expr_subr>,
subr_data=subr_data@entry=0x7ffec0525688, pool=pool@entry=0x7fcdc56c1f00,
err=err@entry=0x7ffec0525600, target=0x7ffec05255f8)
at /home/buildozer/aports/community/rspamd/src/rspamd-1.9.4/src/libutil/expression.c:671
#6 0x00007fcdc52af3a8 in read_regexp_expression (pool=0x7fcdc56c1f00,
--Type <RET> for more, q to quit, c to continue without paging--
symbol=0x56270565c5c0 "SUBJECT_HAS_CURRENCY",
line=line@entry=0x5627056039c0 "Subject=/[$€$¢¥₽]/Hu",
ud=ud@entry=0x7ffec0525688, chain=<optimized out>)
at /home/buildozer/aports/community/rspamd/src/rspamd-1.9.4/src/plugins/regexp.c:81
#7 0x00007fcdc52af799 in regexp_module_config (cfg=0x7fcdc4b39720)
at /home/buildozer/aports/community/rspamd/src/rspamd-1.9.4/src/plugins/regexp.c:228
#8 0x00007fcdc5252b18 in rspamd_init_filters (cfg=0x7fcdc4b39720,
reconfig=false)
at /home/buildozer/aports/community/rspamd/src/rspamd-1.9.4/src/libserver/cfg_utils.c:1539
#9 0x000056270449ca09 in load_rspamd_config (reload=0,
opts=(RSPAMD_CONFIG_INIT_URL | RSPAMD_CONFIG_INIT_LIBS | RSPAMD_CONFIG_INIT_SYMCACHE | RSPAMD_CONFIG_INIT_VALIDATE | RSPAMD_CONFIG_INIT_PRELOAD_MAPS),
init_modules=1, cfg=0x7fcdc4b39720, rspamd_main=0x7fcdc48dd8e0)
at /home/buildozer/aports/community/rspamd/src/rspamd-1.9.4/src/rspamd.c:956
#10 load_rspamd_config (rspamd_main=0x7fcdc48dd8e0, cfg=0x7fcdc4b39720,
init_modules=1,
opts=(RSPAMD_CONFIG_INIT_URL | RSPAMD_CONFIG_INIT_LIBS | RSPAMD_CONFIG_INIT_SYMCACHE | RSPAMD_CONFIG_INIT_VALIDATE | RSPAMD_CONFIG_INIT_PRELOAD_MAPS),
reload=0)
--Type <RET> for more, q to quit, c to continue without paging--
at /home/buildozer/aports/community/rspamd/src/rspamd-1.9.4/src/rspamd.c:924
#11 0x0000562704490511 in main (argc=<optimized out>, argv=<optimized out>,
env=<optimized out>)
at /home/buildozer/aports/community/rspamd/src/rspamd-1.9.4/src/rspamd.c:1385