Skip to content

rspamd: fix crashes by disabling pcre2 jit - #181908

Merged
Mic92 merged 1 commit into
NixOS:masterfrom
Mic92:rspamd
Jul 18, 2022
Merged

Mic92 merged 1 commit into
NixOS:masterfrom
Mic92:rspamd

Conversation

@Mic92

@Mic92 Mic92 commented Jul 18, 2022 •

Copy link
Copy Markdown
Member
Description of changes

Since #179444 we now have pcre2 jit enabled.
However doing so now crashes rspamd2 quite frequently.
This is serious because it can take down mail delivery.

I have seen a lot of crashes like this:

#0  0x00007fbc5165020b in sljit_free_exec () from /nix/store/hzxgmfrn5niii8pvaxf4za2k59jbhlj6-pcre2-10.40/lib/libpcre2-8.so.0
#1  0x00007fbc51682163 in _pcre2_jit_free_8 () from /nix/store/hzxgmfrn5niii8pvaxf4za2k59jbhlj6-pcre2-10.40/lib/libpcre2-8.so.0
#2  0x00007fbc5163b0ca in pcre2_code_free_8 () from /nix/store/hzxgmfrn5niii8pvaxf4za2k59jbhlj6-pcre2-10.40/lib/libpcre2-8.so.0
#3  0x00007fbc51b46368 in rspamd_regexp_dtor () from /nix/store/2zaxxdh1y3wkhm2zrjzwnshx23v7yvg4-rspamd-3.2/lib/rspamd/librspamd-server.so
#4  0x00007fbc51b9d2dc in rspamd_re_cache_elt_dtor () from /nix/store/2zaxxdh1y3wkhm2zrjzwnshx23v7yvg4-rspamd-3.2/lib/rspamd/librspamd-server.so
#5  0x00007fbc4e4f56d0 in ptr_array_free () from /nix/store/i4k2ahrb0rzr7f2ni02nljcffawvpqpg-glib-2.72.3/lib/libglib-2.0.so.0
#6  0x00007fbc51b9d4b5 in rspamd_re_cache_destroy () from /nix/store/2zaxxdh1y3wkhm2zrjzwnshx23v7yvg4-rspamd-3.2/lib/rspamd/librspamd-server.so
#7  0x00007fbc51b691da in rspamd_config_free () from /nix/store/2zaxxdh1y3wkhm2zrjzwnshx23v7yvg4-rspamd-3.2/lib/rspamd/librspamd-server.so
#8  0x000055fdbfb8fe66 in main ()

After applying my disabling the jit in pcre2, they were disappeared.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@ofborg
ofborg Bot requested review from avnik, fpletz, globin and nlewo July 18, 2022 06:30
@ofborg ofborg Bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Jul 18, 2022

@nlewo nlewo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should ping the pcre2 maintainers (https://github.com/PCRE2Project/pcre2).

Otherwise, lgtm.

@trofi

trofi commented Jul 18, 2022 •

Copy link
Copy Markdown
Contributor

I'm always worried to see forking of a frequently used shared library. It has a chance to cause symbol collision: https://trofi.github.io/posts/248-how-do-shared-library-collisions-break.html

I wonder if disabling jemalloc (has a chance to conflict with pcre2's jit malloc) or switching to pcre1 would be safer to do until rspamd is fixed. Both pcre and pcre2 already get loaded in via multiple paths:

$ nix-build -A rspamd
$ lddtree -a ./result/bin/rspamd | fgrep pcre
            libpcre.so.1 => /nix/store/x773khw8rdwwa1pjaw2gdxmghmw08n34-pcre-8.45/lib/libpcre.so.1
        libpcre2-8.so.0 => /nix/store/hzxgmfrn5niii8pvaxf4za2k59jbhlj6-pcre2-10.40/lib/libpcre2-8.so.0
                libpcre.so.1 => /nix/store/x773khw8rdwwa1pjaw2gdxmghmw08n34-pcre-8.45/lib/libpcre.so.1
            libpcre2-8.so.0 => /nix/store/hzxgmfrn5niii8pvaxf4za2k59jbhlj6-pcre2-10.40/lib/libpcre2-8.so.0
                libpcre.so.1 => /nix/store/x773khw8rdwwa1pjaw2gdxmghmw08n34-pcre-8.45/lib/libpcre.so.1
            libpcre.so.1 => /nix/store/x773khw8rdwwa1pjaw2gdxmghmw08n34-pcre-8.45/lib/libpcre.so.1
        libpcre2-8.so.0 => /nix/store/hzxgmfrn5niii8pvaxf4za2k59jbhlj6-pcre2-10.40/lib/libpcre2-8.so.0
    libpcre2-8.so.0 => /nix/store/hzxgmfrn5niii8pvaxf4za2k59jbhlj6-pcre2-10.40/lib/libpcre2-8.so.0
            libpcre.so.1 => /nix/store/x773khw8rdwwa1pjaw2gdxmghmw08n34-pcre-8.45/lib/libpcre.so.1
        libpcre.so.1 => /nix/store/x773khw8rdwwa1pjaw2gdxmghmw08n34-pcre-8.45/lib/libpcre.so.1

@SuperSandro2000

Copy link
Copy Markdown
Member

Since #179444 we now have pcre2 jit enabled.

jit was enabled before that just not for m1 macs.

The linked PR added --enable-jit-sealloc which makes jit work if memory is not executable.

Comment thread pkgs/servers/mail/rspamd/default.nix Resolved
@github-actions github-actions Bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jul 18, 2022
@github-actions github-actions Bot removed 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jul 18, 2022
@ofborg
ofborg Bot requested a review from nlewo July 18, 2022 11:21
on x86-64 the impact should be also minimal because hyperscan is used
for performance critical regexes.
@Mic92

Mic92 commented Jul 18, 2022

Copy link
Copy Markdown
Member Author

Seems not to crash anymore. Performance impact on x86 should be minimal since hyperscan is used as well for regexes.

@Mic92
Mic92 merged commit d8556e0 into NixOS:master Jul 18, 2022
@Mic92
Mic92 deleted the rspamd branch July 18, 2022 11:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants