Skip to content

getaddrinfo() thread failed on HPUX #2697

Closed

Description

@Eason-Yu

I build curl-7.60.0 on HPUX by running "configure && make && sudo make install", then run the following command:
bash-3.1# /usr/local/bin/curl -x dcmfa02-w2k16d.mfa.cdc:8080 --connect-timeout 5 URL -v 2>&1

  • getaddrinfo() thread failed to start

  • Couldn't resolve proxy 'dcmfa02-w2k16d.mfa.cdc'

  • Closing connection 0
    curl: (5) getaddrinfo() thread failed to start`

get a error "getaddrinfo() thread failed to start", then check the lib dependency of curl, pthread lib is not there.

Btw, using LD_PRELOAD specify with pthread lib, then it works well. details as follows:
bash-3.1# LD_PRELOAD=/usr/lib/libpthread.1 /usr/local/bin/curl -x dcmfa02-w2k16d.mfa.cdc:8080 --connect-timeout 5 URL -v 2>&1

  • Trying 10.100.50.50...
  • TCP_NODELAY set
  • Connected to dcmfa02-w2k16d.mfa.cdc (10.100.50.50) port 8080 (#0)
  • allocate connect buffer!
  • Establish HTTP proxy tunnel to xxx

CONNECT xxx HTTP/1.1
Host: xxx
User-Agent: curl/7.60.0
Proxy-Connection: Keep-Alive

< HTTP/1.1 200 Connection established
<

Activity

  1. bagder commented on Jun 29, 2018

    @bagder
    Member

    First, I note that the last curl release is provided as binary builds for HPUX by others so clearly it builds and works for some: https://curl.haxx.se/download.html#HPUX

    To me this sounds like something in your run-time environment makes it not find and use the pthread library and since configure both deemed it present and made use of it, this problem will prevent curl from working correctly.

  2. Eason-Yu commented on Jun 30, 2018

    @Eason-Yu
    Author

    But I use the same commands to build it on RHEL, AIX and Solaris, curl can work well. Just curious why it just can not work on HPUX, seems the building for curl on HPUX needs a different configuration option (e.g. ./configure LIBS="-lpthread"), if so, i think at least curl needs give a doc for it.

  3. bagder commented on Jun 30, 2018

    @bagder
    Member

    configure already checks for your pthreads library and if it fails to find it, it won't enable the threaded resolver in the first place.

    This makes me believe configure found it for you and made use of it correctly (configure's output and even the config.log can confirm that), but then when you use built output, something in your environment makes it not work run-time.

  4. changed the title [-]curl can not work on HPUX[/-] [+]getaddrinfo() thread failed on HPUX[/+] on Jun 30, 2018
  5. Eason-Yu commented on Jun 30, 2018

    @Eason-Yu
    Author

    yes. configure check pthread and find it. But library pthread is not linked into curl on HPUX. Do you try to build the latest version of curl on HPUX? If you did, is library pthread included into the library dependencies of curl?

  6. bagder commented on Jun 30, 2018

    @bagder
    Member

    yes. configure check pthread and find it. But library pthread is not linked into curl on HPUX.

    Can you please show how this happens by pasting/including the relevant bits from the output or config.log file?

    Do you try to build the latest version of curl on HPUX?

    No I don't. I'm still willing to help you nail down this problem and if necessary adjust things to make them work better. To do that, I must first understand what fails with the existing configure logic.

  7. Eason-Yu commented on Jun 30, 2018

    @Eason-Yu
    Author

    I run "configure; make; make install" to build curl, no error occurs except for the following warning during make:
    libtool: warning: this platform does not like uninstalled shared libraries
    libtool: warning: 'curl' will be relinked during installation

    then i check the lib dependencies of curl, pthread is not there. then i gdb debug curl, and found pthread_create always fail, and return errno 251 (function is not available).

    Note: Redhat, Solaris and AIX does not have this issue, and pthread is included into the lib dependencies of the curl on those platforms. just curious, i run the same command, why lib pthread is no t included into the lib dependencies of curl on HPUX.

  8. bagder commented on Jun 30, 2018

    @bagder
    Member

    So I ask again:

    Can you please show how this happens by pasting/including the relevant bits from the configure output or config.log file?

  9. Eason-Yu commented on Jul 1, 2018

    @Eason-Yu
    Author

    Please check config.log. Thanks.

    BTW, want to confirm with you for the following snippet of configure
    ...
    if test "x$ac_cv_func_pthread_create" = xyes; then :
    USE_THREADS_POSIX=1
    fi

    if test "$USE_THREADS_POSIX" != "1" <====== Should it be "$USE_THREADS_POSIX" = 1?
    then
    CFLAGS="$CFLAGS -pthread"
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_create in -lpthread" >&5
    $as_echo_n "checking for pthread_create in -lpthread... " >&6; }
    if ${ac_cv_lib_pthread_pthread_create+:} false; then :
    $as_echo_n "(cached) " >&6
    else
    ac_check_lib_save_LIBS=$LIBS
    ...

  10. bagder commented on Jul 1, 2018

    @bagder
    Member

    if test "$USE_THREADS_POSIX" != "1" <====== Should it be "$USE_THREADS_POSIX" = 1?

    No. That check is there to see if it isn't enabled yet and if so, do some additional checks. This code

    But what's curious about your config.log is that when configure checks if it can find and use pthread_create without any additional libraries provided, it succeeds! (line 60037 of your attached log file). Since it actually works to build a program using that function without any additional libs it is of course deemed unnecessary to add one. What puzzles me is of course why this works (and it also doesn't cause any link errors when you then go on to build curl which then uses the pthread functions)... and you only get the problems at run-time. Can you understand why this is so?

  11. Eason-Yu commented on Jul 1, 2018

    @Eason-Yu
    Author

    I'm not sure. But I suspect the checking for pthread_create. line 60037 just tell the conftest is built successfully, but it does not tell if pthread_create is available or not.
    I wrote a small test program (e.g. conftest.c) on HPUX, as follows:
    #include <pthread.h> int main (void) { return pthread_create (NULL, NULL,, NULL, NULL); }
    $ gcc -o conftest conftest.c <<<===== No link errors.
    $ ./conftest
    $ echo $?
    251

    I have checked this issue for two days, and i'm not familiar with the building. If you have a HPUX, i think it should be able to be reproduced easily.

  12. bagder commented on Jul 1, 2018

    @bagder
    Member

    line 60037 just tell the conftest is built successfully, but it does not tell if pthread_create is available or not

    That's not how linking generally works. The linker should check that the functions are available! This is clearly the reason why the pthread check fails on this system...

    I don't have an HPUX system and I never had. I logged into one though, once. Like 17 years ago or so...

  13. Eason-Yu commented on Jul 2, 2018

    @Eason-Yu
    Author

    Google a lot. Found the reason pthread_create is failing with error 251 is the libc library provides stubs for the pthread functions on HPUX. So no link error does not mean you don't need to link pthread library on HPUX.

    Do you think you (configure.ac) should deal with this exception on HPUX? If so, can you provide me a patch for this issue?

  14. bagder commented on Jul 2, 2018

    @bagder
    Member

    can you provide me a patch for this issue?

    Can you try this patch and see if this works for you? It's a bit "crude" as it checks fox hpux specifically, but I really can't figure out a really nice way to do this.

    You need to apply the patch and run ./buildconf, then you can run configure again.

    --- a/configure.ac
    +++ b/configure.ac
    @@ -3779,10 +3779,20 @@ if test "$want_pthreads" != "no"; then
           save_CFLAGS="$CFLAGS"
     
           dnl first check for function without lib
           AC_CHECK_FUNC(pthread_create, [USE_THREADS_POSIX=1] )
     
    +      dnl on HPUX, life is more complicated...
    +      case $host in
    +      *-hp-hpux*)
    +         dnl it doesn't actually work without -lpthread
    +         USE_THREADS_POSIX=""
    +         ;;
    +      *)
    +         ;;
    +      esac
    +
           dnl if it wasn't found without lib, search for it in pthread lib
           if test "$USE_THREADS_POSIX" != "1"
           then
             CFLAGS="$CFLAGS -pthread"
             AC_CHECK_LIB(pthread, pthread_create,
    
  15. Eason-Yu commented on Jul 2, 2018

    @Eason-Yu
    Author

    It's really a bit "crude". how about using AC_TRY_RUN?

  16. bagder commented on Jul 2, 2018

    @bagder
    Member

    AC_TRY_RUN must be avoided as far as possible since it breaks cross-compilation. Since I rather have this "crudeness" limited to HPUX-only such a AC_TRY_RUN could be restricted to HPUX but then it seems like maybe not necessary? Do you think there's a risk different HPUX systems work differently in regards to the pthreads library?

  17. Eason-Yu commented on Jul 2, 2018

    @Eason-Yu
    Author

    I'm not sure. I would like to have a elegant way to fix it, but i'm not familiar with autoconf. So ask your help here.

  18. bagder commented on Jul 2, 2018

    @bagder
    Member

    And I have no HPUX system to test on so working on an "elegant fix" is not up to me. I can't think of a proper way to fix this detection while at the same time avoiding AC_TRY_RUN, but I don't want to "hurt" all other users because of this HPUX weirdness.

    An alternative would be to check if cross-compilation is being done, and only do the extra AC_TRY_RUN check if not.

  19. bagder commented on Aug 24, 2018

    @bagder
    Member

    So @Eason-Yu, does the "crude" approach work at all? If so, it might be a better idea to land that than doing nothing?

  20. michael-o commented on Aug 25, 2018

    @michael-o
    Contributor

    I might jump into this next month. I have been using HP-UX for the last 10 years, but haven't compiled curl on HP-UX for quite some time.

  21. Eason-Yu commented on Aug 30, 2018

    @Eason-Yu
    Author

    @bagder Sorry for the delay. It works. Thanks a lot.

  22. added a commit that references this issue on Sep 21, 2018
    b8fc885
  23. locked as resolved and limited conversation to collaborators on Dec 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions