Page MenuHome GnuPG

gpg-agent: error allocating thread attributes when starting as daemon
Closed, ResolvedPublic

Description

Launching gpg-agent 2.2.7 as daemon produces the following error and then quits:

gpg-agent[19693]: Fatal: error allocating thread attributes: Function is not available

Running on HP-UX 11.31.

I am able to run gpg-agent version 2.0.30 with nearly the same libraries successfully. The only difference is the use of pth in version 2.0.30 vs. npth 1.5 in version 2.2.7. The tests that came with the build of npth 1.5 ran successfully.

Details

Version
2.2.7

Revisions and Commits

Event Timeline

werner added a project: npth.
werner added a subscriber: werner.

That comes directly from pthread_attr_init - need to check what's special on HP/UX here.

ENOSYS means it's linked to stub.
http://nixdoc.net/man-pages/HP-UX/man5/pthread_stubs.5.html
Somehow the build process may be wrong for the gpg-agent executable.

Thanks. That appears to be the exact issue. I was able to get around it with export LD_PRELOAD as indicated in the man page. Any ideas on how to address it in the make? This is what I see when I do an ldd on gpg-agent:

gpg-agent:

libgcrypt.so.22 
libgpg-error.so.24 
libassuan.so.8 
libnpth.so.1 
libiconv.so.8 
libc.so.1 
libc.so.1 
libc.so.1 
libpthread.so.1 
librt.so.1 
libm.so.1 
libc.so.1 
libdl.so.1

This is 32-bit, so I think the order is reversed(?) but I see libc before and after libpthread. I'm not sure how to fix that, though. The only place I saw -lpthread in the agent Makefile was on the GPG_ERROR_MT_LIBS line, so I moved it before -lgpg-error, but it didn't seem to have any effect.

Thanks for quick feedback.
Yes, it is a build problem, which should be handled by configure + make.
Could you please upload the build log here, so that I can check it to fix configure.ac+Makefile.am?

I have uploaded config.log. Let me know if you need any additional information/files. Thanks!

Thanks for config.log of GnuPG. I think that I located the problem; While gpg-agent should be linked to -lpthread, it was not. The configure variable NPTH_LIBS in config.log doesn't have -lpthread. Thus, pthread_* are linked to the ones of stub, and it resulted the error.

I think that that's because npth was not built correctly.

This is a patch for npth:

Could you please test it out?

Rebuilding npth results in three unsatisfied symbols:

ld: (Warning) Unsatisfied symbol "sem_init"
ld: (Warning) Unsatisfied symbol "sem_post"
ld: (Warning) Unsatisfied symbol "sem_wait"

I believe I had this issue previously, and then may have manually changed the Makefile which possibly caused the original issue. What would be the proper way to resolve these symbols?

Thanks for your testing, it's near. Here is updated patch:


I think that HP-UX is just like *BSD for pthread and POSIX semaphore.
It is also good to add a test case. I will.

I realized that the test case is already there.
I'm not sure the reason why make check for npth works well on HP-UX (before the my patch). It uses npth_attr_init (hence, pthread_attr_init) in tests/t-thread.c.
Perhaps, libtool is clever enough to detect -lpthread into src/libnpth.la (dependency_libs), I suppose.

I tried with the updated patch, but I still see the same unsatisfied symbols during link. I verified that the patch was in place in configure.ac and also patched a clean version of configure.ac so that there would be only one instance of hpux in the case statement:

*-*-dragonfly*|*-*-freebsd*|*-*-netbsd*|*-*-hpux*)
    LIBS="-lpthread $LIBS"
    AC_SEARCH_LIBS([sem_init],[rt])
    ;;

It seems like it's still not finding the library it needs.

Could you please put the config.log of npth with the patch?
The intention of change is: we need to link -lpthread and -lrt

config.log is attached.

Apparently, the check of sem_init function was not done (in config.log).
Could you please make sure to update npth/configure by npth/autogen.sh?

Thanks, that allowed npth to make successfully without the unsatisfied symbols.

I then re-ran the configure for gpg and now -lpthread is in NPTH_LIBS.

Re-ran the make for gpg and gpg-agent now starts as daemon without errors.

All is well now. Thank you for your help!!

gniibe changed the task status from Open to Testing.May 28 2018, 2:11 AM
werner closed subtask T4027: npth 1.6 as Resolved.