Page MenuHome GnuPG

dirmngr with libgcrypt 1.6.0 forgets to initialize pth properly
Closed, WontfixPublic

Description

libgcrypt-1.6.0 breaks dirmngr-1.1.1:

Running dirmngr (without arguments) causes a segmentation fault while executing
the line

     if (pth_current->data_value == NULL) {

in line 68 of pth-2.0.7/pth_data.c because pth_current is NULL. The above line
is part of the function pth_key_setdata() called in the function main() in line
723 of dirmngr-1.1.1/src/dirmngr.c

The reason of pth_current being NULL is that the function
gcry_control(GCRYCTL_SET_THREAD_CBS,...) of libgcrypt, called in main() in line
671 of dirmngr-1.1.1/src/dirmngr.c, does no longer cause it being initialized.
(I could not yet find out why.)

By adding the following line after line 671 of dirmngr.c, you can see the value
of pth_current after calling gcry_control(GCRYCTL_SET_THREAD_CBS,...) and before
the segmentation fault occurs:

{extern pth_t
pth_current;fprintf(stderr,"%08lx\n",(long)pth_current);fflush(stderr);}

My configure options (I use the latest versions of the sources), even if
probably irrelevant for the problem:

pth: --enable-static --disable-shared
libgpg-error: --enable-static --disable-shared
libassuan: --enable-static --disable-shared --with-gpg-error-prefix=$prefix
libgcrypt: --enable-static --disable-shared --with-gpg-error-prefix=$prefix
libksba: --enable-static --disable-shared --with-gpg-error-prefix=$prefix
dirmngr: --with-gpg-error-prefix=$prefix \

--with-pth-prefix=$prefix --with-libassuan-prefix=$prefix \
--with-libgcrypt-prefix=$prefix --with-ksba-prefix=$prefix

pinentry: --disable-pinentry-gtk2
gnupg-2: --with-gpg-error-prefix=$prefix \

--with-pth-prefix=$prefix --with-libassuan-prefix=$prefix \
--with-libgcrypt-prefix=$prefix --with-ksba-prefix=$prefix \
--with-dirmngr-pgm=$prefix/bin/dirmngr

--with-pinentry-pgm=$prefix/bin/pinentrywrapper

Switching back to libgcrypt-1.5.3 removed the problem for me.

Details

Version
1.6.0

Event Timeline

Will you be so kind and test the attached patch?

Looks good, compiling with libgcrypt-1.6.0 and creating a signed S/MIME e-mail
with gpgsm works.

Thanks.

Changing category to dismngr to remind about doing a release.

aheinecke added a subscriber: aheinecke.

With dirmngr 1.1.1 and libgcrypt-1.6.0 (gpg4win-2.2.2-beta19) I have what I
think is a similar error on Windows:

C:\Users\aheinecke>"c:\Program Files\GNU\GnuPG\dirmngr.exe"
dirmngr[3060]: Fatal: can't register GNU Pth with Libgcrypt: Not supported

Doesn't crash though. I've not tested the pth_init patch. If you think this is
useful please tell me and I will do so. I assume it will also fix this problem.

werner renamed this task from libgcrypt 1.6.0 forgets to initialize pth properly to dirmngr with libgcrypt 1.6.0 forgets to initialize pth properly.Aug 11 2014, 5:16 PM

Compiling with latest npth instead of latest pth does not change anything.
Without patch = segfault, with patch = works.

werner lowered the priority of this task from Unbreak Now! to Normal.Apr 3 2017, 10:59 PM

Libgcrypt 1.6 reaches EOL in 7 days, so we won't fix it.