Bug 261358 - ftp/pure-ftpd: 1.0.50 crashes (SIGSEGV) after user login with PostgreSQL backend
Summary: ftp/pure-ftpd: 1.0.50 crashes (SIGSEGV) after user login with PostgreSQL backend
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Po-Chuan Hsieh
URL: https://github.com/jedisct1/pure-ftpd...
Keywords: crash, needs-qa
Depends on:
Blocks:
 
Reported: 2022-01-20 16:55 UTC by Artyom Davidov
Modified: 2022-01-23 20:45 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (sunpoet)
koobs: merge-quarterly?


Attachments
ftp/pure-ftpd build log (91.33 KB, text/plain)
2022-01-20 16:55 UTC, Artyom Davidov
no flags Details
Patch for the FreeBSD ports tree to fix SIGSEGV (1.81 KB, patch)
2022-01-20 23:49 UTC, Artyom Davidov
ard_1: maintainer-approval? (sunpoet)
Details | Diff
Patched pure-ftpd build log (90.00 KB, text/plain)
2022-01-20 23:53 UTC, Artyom Davidov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Artyom Davidov 2022-01-20 16:55:57 UTC
Created attachment 231180 [details]
ftp/pure-ftpd build log

The latest version 1.0.50 of the pure-ftpd SIGSEGV on FreeBSD 13-RELEASE-p6 just after a user login when the PostgreSQL is being used as a user database back-end.

The same server configuration was working fine with the previous version 1.0.49 of the pure-ftpd server.

There are some warnings were spotted in the pure-ftpd build log in the section that corresponds to PostgreSQL module, but I'm not sure if those warning are the real source of those SIGSEGV.

I tried to attach the lldb debugger to the pure-ftpd process just before the SIGSEGV and got the following info:
----
(lldb) attach -p 15274
Process 15274 stopped

Executable module set to "/usr/local/sbin/pure-ftpd".
Architecture set to: x86_64--freebsd13.0.
(lldb) continue
Process 15274 resuming
Process 15274 stopped
* thread #1, name = 'pure-ftpd', stop reason = signal SIGSEGV: invalid address (fault address: 0x1538)
    frame #0: 0x000000080177025f libc.so.7`strlen + 31
libc.so.7`strlen:
->  0x80177025f <+31>: movq   (%rcx), %rax
    0x801770262 <+34>: movq   %rax, %rdx
    0x801770265 <+37>: notq   %rdx
    0x801770268 <+40>: addq   %r8, %rax
(lldb) bt
* thread #1, name = 'pure-ftpd', stop reason = signal SIGSEGV: invalid address (fault address: 0x1538)
  * frame #0: 0x000000080177025f libc.so.7`strlen + 31
    frame #1: 0x00000000010459ca pure-ftpd`___lldb_unnamed_symbol149$$pure-ftpd + 42
    frame #2: 0x000000000104462c pure-ftpd`___lldb_unnamed_symbol144$$pure-ftpd + 684
    frame #3: 0x0000000001034760 pure-ftpd`___lldb_unnamed_symbol34$$pure-ftpd + 544
    frame #4: 0x0000000001042338 pure-ftpd`___lldb_unnamed_symbol128$$pure-ftpd + 1048
    frame #5: 0x000000000103ddc8 pure-ftpd`___lldb_unnamed_symbol68$$pure-ftpd + 3816
    frame #6: 0x000000000103e917 pure-ftpd`___lldb_unnamed_symbol74$$pure-ftpd + 903
    frame #7: 0x000000000103cbd4 pure-ftpd`___lldb_unnamed_symbol66$$pure-ftpd + 6276
    frame #8: 0x0000000001030922 pure-ftpd
----
but since the executable built from ports doesn't contain any debug symbols this info is merely useless.

I need some help in building this port with the debug symbols enabled to be able to trace this issue further.
Comment 1 Artyom Davidov 2022-01-20 23:49:52 UTC
Created attachment 231197 [details]
Patch for the FreeBSD ports tree to fix SIGSEGV

I've contacted the pure-ftpd author directly and thanks to his quick response here is the patch for the FreeBSD ports tree that fix this SIGSEGV issue with the PostgreSQL backend.
This patch is based on a recent commit to pure-ftpd at GitHub and it is tested to apply cleanly to the pure-ftpd 1.0.50 branch on a FreeBSD 13-RELEASE-p6 host.
The original commit address is:
https://github.com/jedisct1/pure-ftpd/commit/c3f0f3c91d86939e6fabf5f65c6c6fc964e6032e
Comment 2 Artyom Davidov 2022-01-20 23:53:11 UTC
Created attachment 231199 [details]
Patched pure-ftpd build log

Here is Synth test build log for the patched pure-ftpd on a FreeBSD 13-RELEASE-p6 amd64 host.
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-01-23 19:33:57 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b2bd4ad8c484a613957005212289963a6b249445

commit b2bd4ad8c484a613957005212289963a6b249445
Author:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
AuthorDate: 2022-01-23 18:26:38 +0000
Commit:     Po-Chuan Hsieh <sunpoet@FreeBSD.org>
CommitDate: 2022-01-23 19:09:47 +0000

    ftp/pure-ftpd: Fix SIGSEGV with PostgeSQL backend

    - Bump PORTREVISION for package change

    PR:             261358
    Reported by:    Artyom Davidov <ard_1@mail.ru>
    Obtained from:  https://github.com/jedisct1/pure-ftpd/commit/c3f0f3c91d86939e6fabf5f65c6c6fc964e6032e

 ftp/pure-ftpd/Makefile                          |  1 +
 ftp/pure-ftpd/files/patch-src-log_pgsql.c (new) | 29 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
Comment 4 Po-Chuan Hsieh freebsd_committer freebsd_triage 2022-01-23 20:45:58 UTC
Committed. Thanks!