Bug 272472 - security/gnupg: dirmngr crashes with segfault after devel/gettext-runtime is updated to 0.22
Summary: security/gnupg: dirmngr crashes with segfault after devel/gettext-runtime is ...
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: Tijl Coosemans
URL:
Keywords:
Depends on:
Blocks: 272589
  Show dependency treegraph
 
Reported: 2023-07-12 15:38 UTC by Yasuhiro Kimura
Modified: 2023-07-19 06:53 UTC (History)
3 users (show)

See Also:


Attachments
patch-dirmngr_Makefile.in (585 bytes, patch)
2023-07-12 20:03 UTC, Tijl Coosemans
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yasuhiro Kimura freebsd_committer freebsd_triage 2023-07-12 15:38:52 UTC
dirmngr crashes with segfault after devel/gettext-runtime is updated to 0.22.

----------------------------------------------------------------------
yasu@rolling-vm-freebsd6[1027]% pkg info -d gnupg-2.4.3
gnupg-2.4.3:
        pinentry-1.2.1
        libksba-1.6.3
        libgpg-error-1.47
        libgcrypt-1.10.2
        libassuan-2.5.6
        gnutls-3.7.9
        indexinfo-0.3.1
        readline-8.2.1
        npth-1.6
        gettext-runtime-0.22
        sqlite3-3.42.0,1
yasu@rolling-vm-freebsd6[1030]% dirmngr --version
zsh: segmentation fault (core dumped)  dirmngr --version
yasu@rolling-vm-freebsd6[1031]% 
----------------------------------------------------------------------

If I revert the latter to 0.21.1, then the crash disappears

----------------------------------------------------------------------
yasu@rolling-vm-freebsd6[1035]% pkg info -d gnupg-2.4.3
gnupg-2.4.3:
        pinentry-1.2.1
        libksba-1.6.3
        libgpg-error-1.47
        libgcrypt-1.10.2
        libassuan-2.5.6
        gnutls-3.7.9
        indexinfo-0.3.1
        readline-8.2.1
        npth-1.6
        gettext-runtime-0.21.1
        sqlite3-3.42.0,1
yasu@rolling-vm-freebsd6[1036]% dirmngr --version
dirmngr (GnuPG) 2.4.3
Copyright (C) 2023 g10 Code GmbH
License GNU GPL-3.0-or-later <https://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.
yasu@rolling-vm-freebsd6[1037]%
----------------------------------------------------------------------

CC-ing the maintainer of devel/gettext-runtime.
Comment 1 Tijl Coosemans freebsd_committer freebsd_triage 2023-07-12 20:03:51 UTC
Created attachment 243362 [details]
patch-dirmngr_Makefile.in

See if rebuilding gnupg with this patch in security/gnupg/files/ fixes it.
Comment 2 Yasuhiro Kimura freebsd_committer freebsd_triage 2023-07-12 21:05:31 UTC
(In reply to Tijl Coosemans from comment #1)

By applying attached patch dirmngr works file without crash.

Thank you!
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-07-13 13:28:33 UTC
A commit in branch main references this bug:

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

commit 7fa24cff0d8a99e5d44839d4b358fafaf69cffbe
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2023-07-13 11:38:14 +0000
Commit:     Tijl Coosemans <tijl@FreeBSD.org>
CommitDate: 2023-07-13 12:44:44 +0000

    security/gnupg: Fix dirmngr crash caused by gettext 0.22

    Link the threading library after libgpg-error (and libgcrypt, which also
    links to libgpg-error) so the threading library is initialised before
    libgpg-error.  The initialisation function of libgpg-error calls gettext
    functions that call threading functions (mutex locking).

    PR:             272472
    Tested by:      yasu

 security/gnupg/Makefile                              |  1 +
 security/gnupg/files/patch-dirmngr_Makefile.in (new) | 12 ++++++++++++
 2 files changed, 13 insertions(+)
Comment 4 Mark Millard 2023-07-17 14:14:12 UTC
https://lists.freebsd.org/archives/dev-commits-src-main/2023-July/017009.html

from Sunday is for "git: ad056b5d35d9 - main - libthr: trigger library initialization on rwlock calls" in FreeBSD main (so: 14)
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-07-17 18:56:23 UTC
A commit in branch main references this bug:

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

commit fb889ca82944e04d4b3dfa2a13c51456bbde0094
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2023-07-17 13:06:02 +0000
Commit:     Tijl Coosemans <tijl@FreeBSD.org>
CommitDate: 2023-07-17 18:53:17 +0000

    devel/gettext-runtime: Fix crash triggered by libgpg-error

    Libgpg-error has an initialisation function with
    __attribute__((constructor)) that calls a libintl function that
    calls pthread_rwlock_wrlock that segfaults if libpthread wasn't
    initialised yet.  This can happen because libintl doesn't link to
    libpthread to avoid the overhead for non-threaded programs.  To
    fix this, add an initialisation function to libintl that triggers
    initialisation of libpthread.

    RTLD_NOLOAD suggested by kib.

    dlopen was fixed to work during initialisation in
    https://cgit.FreeBSD.org/src/commit/?id=1005d3d05362

    PR:             272472, 272517

 Mk/Uses/gettext-runtime.mk                         |  5 ++--
 devel/gettext-runtime/Makefile                     |  2 +-
 .../gettext-runtime/files/patch-intl_osdep.c (new) | 28 ++++++++++++++++++++++
 3 files changed, 32 insertions(+), 3 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2023-07-17 19:11:27 UTC
A commit in branch main references this bug:

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

commit d0cbe7ba85c00f24f4b85a2c6221533e6a4db44d
Author:     Tijl Coosemans <tijl@FreeBSD.org>
AuthorDate: 2023-07-17 18:59:17 +0000
Commit:     Tijl Coosemans <tijl@FreeBSD.org>
CommitDate: 2023-07-17 19:08:47 +0000

    Revert "security/gnupg: Fix dirmngr crash caused by gettext 0.22"

    This reverts commit 7fa24cff0d8a99e5d44839d4b358fafaf69cffbe.

    The problem has been fixed in libintl in fb889ca82944.

    PR:             272472

 security/gnupg/Makefile                               |  2 +-
 security/gnupg/files/patch-dirmngr_Makefile.in (gone) | 12 ------------
 2 files changed, 1 insertion(+), 13 deletions(-)