This is the mail archive of the libc-help@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]

Re: getaddrinfo thread-safe?


On 24/03/15 02:27, Carlos O'Donell wrote:
> Please debug a bit further and see if you can suss out what's actually
> going on and which writes are conflicting. Your sources don't appear to
> line up with master, so I would suggest a simple test case using:
> -Wl,--dynamic-linker and -Wl,-rpath.
I'm unable to use the master version of glibc, as I don't know how to
compile it, and use it.
I am, however, using eglib on Ubuntu, which is inevitably outdated.
Could you compile the source I   linked, and run the valgrind on it,
using the latest glibc?

Running "valgrind --tool=helgrind --read-var-info=yes ./a.out" also
displays warnings,

However, taking a look at the error:
> ==12380== Conflicting load by thread 2 at 0x09860aa0 size 4
> ==12380==    at 0x964FF48: reopen (res_send.c:981)
> ==12380==    by 0x9651098: __libc_res_nsend (res_send.c:1031)
> ==12380==    by 0x964EE04: __libc_res_nquery (res_query.c:226)
> ==12380==    by 0x964F7F8: __libc_res_nsearch (res_query.c:582)
> ==12380==    by 0x94427E3: _nss_dns_gethostbyname3_r (dns-host.c:192)
> ==12380==    by 0x9442A83: _nss_dns_gethostbyname2_r (dns-host.c:257)
> ==12380==    by 0x5172568: gethostbyname2_r@@GLIBC_2.2.5
> (getXXbyYY_r.c:266)
> ==12380==    by 0x5132226: gaih_inet (getaddrinfo.c:586)
> ==12380==    by 0x5134E0C: getaddrinfo (getaddrinfo.c:2406)
> ==12380==    by 0x40096F: doit (k.c:39)
> ==12380==    by 0x4C30E7B: ??? (in
> /usr/lib/valgrind/vgpreload_drd-amd64-linux.so)
> ==12380==    by 0x4E4F181: start_thread (pthread_create.c:312)
> ==12380== Location 0x9860aa0 is 0 bytes inside global var
> "__have_o_nonblock"
> ==12380== declared at res_send.c:108
> ==12380== Other segment start (thread 5)
> ==12380==    at 0x4C34544: pthread_mutex_unlock (in
> /usr/lib/valgrind/vgpreload_drd-amd64-linux.so)
> ==12380==    by 0x7032593: _nss_files_gethostbyname3_r (files-hosts.c:351)
> ==12380==    by 0x7032BC3: _nss_files_gethostbyname2_r (files-hosts.c:372)
> ==12380==    by 0x5172568: gethostbyname2_r@@GLIBC_2.2.5
> (getXXbyYY_r.c:266)
> ==12380==    by 0x5132226: gaih_inet (getaddrinfo.c:586)
> ==12380==    by 0x5134E0C: getaddrinfo (getaddrinfo.c:2406)
> ==12380==    by 0x40096F: doit (k.c:39)
> ==12380==    by 0x4C30E7B: ??? (in
> /usr/lib/valgrind/vgpreload_drd-amd64-linux.so)
> ==12380==    by 0x4E4F181: start_thread (pthread_create.c:312)
> ==12380==    by 0x515F47C: clone (clone.S:111)
> ==12380== Other segment end (thread 5)
> ==12380==    at 0x515212D: ??? (syscall-template.S:81)
> ==12380==    by 0x96511E2: __libc_res_nsend (res_send.c:1067)
> ==12380==    by 0x964EE04: __libc_res_nquery (res_query.c:226)
> ==12380==    by 0x964F7F8: __libc_res_nsearch (res_query.c:582)
> ==12380==    by 0x94427E3: _nss_dns_gethostbyname3_r (dns-host.c:192)
> ==12380==    by 0x9442A83: _nss_dns_gethostbyname2_r (dns-host.c:257)
> ==12380==    by 0x5172568: gethostbyname2_r@@GLIBC_2.2.5
> (getXXbyYY_r.c:266)
> ==12380==    by 0x5132226: gaih_inet (getaddrinfo.c:586)
> ==12380==    by 0x5134E0C: getaddrinfo (getaddrinfo.c:2406)
> ==12380==    by 0x40096F: doit (k.c:39)
> ==12380==    by 0x4C30E7B: ??? (in
> /usr/lib/valgrind/vgpreload_drd-amd64-linux.so)
> ==12380==    by 0x4E4F181: start_thread (pthread_create.c:312)

It's complaining about:
==12380== Location 0x9860aa0 is 0 bytes inside global var
"__have_o_nonblock"
==12380== declared at res_send.c:108

with:

> #ifndef __ASSUME_SOCK_CLOEXEC
> static int __have_o_nonblock;
> #else
> # define __have_o_nonblock 0
> #endif


In the code of reopen:
> static int
> reopen (res_state statp, int *terrno, int ns)

>                                         __have_o_nonblock
>                                           = (EXT(statp).nssocks[ns] == -1
>                                              && errno == EINVAL ? -1 : 1);
And that is why it complains, probably.

Please check the vanilla glibc code.

Thanks,

-- 
-- Joshua Rogers <https://internot.info/>

Attachment: signature.asc
Description: OpenPGP digital signature


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