Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upDoes getaddrinfo need to take the ENV lock? #27970
Comments
This comment has been minimized.
This comment has been minimized.
|
cc @luqmana |
This comment has been minimized.
This comment has been minimized.
|
If we did take this route I'd want to convert the environment lock to a rwlock to ensure that we could at least have parallel dns queries. Also cc #27705. |
This comment has been minimized.
This comment has been minimized.
|
Yeah, either way the situation is tricky. We get tangled up in glibc internals. |
This comment has been minimized.
This comment has been minimized.
|
I found the wording on this page also particularly interesting:
The getaddrinfo function is indeed marked with this tag |
steveklabnik
added
the
A-libs
label
Aug 24, 2015
This comment has been minimized.
This comment has been minimized.
fweimer
commented
Dec 3, 2016
•
|
Even without low-level races, This problem would not go away if we provided thread-safe environment access at the libc layer. Therefore, I'm surprised the function isn't marked |
bluss commentedAug 23, 2015
Like the documentation for our
set_var(setenv) says, care must be taken with mutating environment variables in a multithreaded program. See this glibc bug #13271 that says getaddrinfo may call getenv.It looks like we have an unsynchronized call to getaddrinfo and this may cause trouble with glibc/Linux.
Seeing glibc's attitude to setenv in multithreaded programs,
set_varseems like a big hazard in general(?).Discovered as an issue tangential to #27966
cc @alexcrichton