Uploaded image for project: 'C Driver'
  1. C Driver
  2. CDRIVER-1413

Segfault on getaddrinfo when client connects on TCP

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 1.3.5
    • Component/s: Bulk API
    • Labels:
      None
    • Environment:
      Debian Jessie with libc 2.19-18+deb8

      On a multithread client, I have a segfault with bulk operations.
      In the stacktrace, you can see that the problem happens when mongoc client call the gethostbyname method in libc.

      #0  0x00007ffff744b833 in _IO_un_link () from /lib/x86_64-linux-gnu/libc.so.6
      #1  0x00007ffff743f775 in fclose () from /lib/x86_64-linux-gnu/libc.so.6
      #2  0x00007ffff2072f11 in _nss_files_gethostbyname3_r ()
         from /lib/x86_64-linux-gnu/libnss_files.so.2
      #3  0x00007ffff2073524 in _nss_files_gethostbyname2_r ()
         from /lib/x86_64-linux-gnu/libnss_files.so.2
      #4  0x00007ffff74cfe39 in gethostbyname2_r ()
         from /lib/x86_64-linux-gnu/libc.so.6
      #5  0x00007ffff74aa4bf in ?? () from /lib/x86_64-linux-gnu/libc.so.6
      #6  0x00007ffff74abafd in getaddrinfo () from /lib/x86_64-linux-gnu/libc.so.6
      #7  0x00007ffff62f0617 in mongoc_client_connect_tcp (uri=0x7ffff777d780,
          uri@entry=0x7fffe4000a80, host=0x7fffe40031c8, error=0x7ffff2a7ac40)
          at src/mongoc/mongoc-client.c:118
      #8  0x00007ffff62f0a36 in mongoc_client_default_stream_initiator (
          uri=0x7fffe4000a80, host=0x7fffe40031c8, user_data=0x7fffe4000950,
          error=0x7ffff2a7ac40) at src/mongoc/mongoc-client.c:310
      #9  0x00007ffff62f5014 in _mongoc_cluster_add_node (error=0x7ffff2a7ac40,
          sd=0x7fffe40031c0, cluster=0x7fffe4000968)
          at src/mongoc/mongoc-cluster.c:1285
      #10 mongoc_cluster_fetch_stream_pooled (error=0x7ffff2a7ac40,
          reconnect_ok=true, sd=0x7fffe40031c0, cluster=0x7fffe4000968)
          at src/mongoc/mongoc-cluster.c:1563
      #11 _mongoc_cluster_stream_for_server_description (
          cluster=cluster@entry=0x7fffe4000968, sd=sd@entry=0x7fffe40031c0,
          reconnect_ok=reconnect_ok@entry=true, error=error@entry=0x7ffff2a7ac40)
          at src/mongoc/mongoc-cluster.c:1365
      #12 0x00007ffff62f561d in _mongoc_cluster_stream_for_optype (
          cluster=0x7fffe4000968, optype=<optimized out>,
          read_prefs=<optimized out>, error=0x7ffff2a7ac40)
          at src/mongoc/mongoc-cluster.c:1701
      #13 0x00007ffff62ef954 in mongoc_bulk_operation_execute (bulk=0x7fffe40028c0,
          reply=0x35000002, reply@entry=0x7fffe40008c0, error=0x1d621,
          error@entry=0x7ffff2a7ac40) at src/mongoc/mongoc-bulk-operation.c:427
      

      In the doc, the getaddrinfo is described as "Thread safety".
      Do you think that is a problem in mongoc driver or in the libc ?

            Assignee:
            Unassigned Unassigned
            Reporter:
            lafeuil Thomas Champagne
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: