This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug nss/20874] New: getaddrinfo_a segfault


https://sourceware.org/bugzilla/show_bug.cgi?id=20874

            Bug ID: 20874
           Summary: getaddrinfo_a segfault
           Product: glibc
           Version: 2.24
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: nss
          Assignee: unassigned at sourceware dot org
          Reporter: swbza at bluematt dot me
  Target Milestone: ---

The following code segfaults after running for a while (a few minutes on some
systems I've tested on), or very quickly if you allow it to run with more
threads by uncommenting the thread starting. I could be calling it wrong, but
it seems to mesh with the man page to me.


#define _GNU_SOURCE
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>

#include <string>
#include <thread>

const char *host = "bluematt.me";

void beatit() {
        struct gaicb gai;
        struct gaicb *gaip = &gai;

        while (1) {
                memset(&gai, 0, sizeof(gai));

                fprintf(stderr, "OK, cleared gai, now calling gai_a\n");
                std::string hostname(host);
                gai.ar_name = hostname.c_str();

                assert(!getaddrinfo_a(GAI_NOWAIT, &gaip, 1, NULL));

                struct timespec ts = { 0, 42 };
                gai_suspend(&gaip, 1, &ts);

                while (gai_cancel(gaip) == EAI_NOTCANCELED)
                        gai_suspend(&gaip, 1, &ts);
        }

}

int main(int argc, char *argv[]) {
        std::thread t1(beatit);
        /*std::thread t2(beatit);
        std::thread t3(beatit);
        std::thread t4(beatit);
        std::thread t5(beatit);
        std::thread t6(beatit);*/

        while (true) {}
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]