<div dir="ltr">With your help I've convinced myself that modern Mac OS X's getaddrinfo is indeed thread-safe on version 10.10. I wrote up my findings in a CPython bug report:<div><br></div><div><a href="http://bugs.python.org/issue25924">http://bugs.python.org/issue25924</a><br></div><div><br></div><div>Now I just need to get my hands on a machine running Mac OS X 10.4 and confirm that getaddrinfo is NOT thread-safe there....</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 4, 2016 at 9:00 AM, Steve <span dir="ltr"><<a href="mailto:steve.b@osfda.org" target="_blank">steve.b@osfda.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Sometimes they do things like that for backlevel compatibility; so
single threaded apps that rely on that global don't immediately
break.<br>
The question is: does ds_getaddrinfo _rely_ on that variable?<br>
<br>
I doubt it; but it's _possible_ you found an oversight!<div><div class="h5"><br>
<br>
<br>
<div>On 1/3/2016 10:57 AM, A. Jesse Jiryu
Davis wrote:<br>
</div>
</div></div><blockquote type="cite"><div><div class="h5">
<div dir="ltr">Thanks for the pointers, with your help I'm making
progress. I think I found the source for Apple's getaddrinfo.
<div><br>
</div>
<div>In Apple's Libinfo version 222.4.12, the man page says
getaddrinfo isn't thread-safe:
<div><br>
</div>
<div><a href="http://www.opensource.apple.com/source/Libinfo/Libinfo-222.4.12/lookup.subproj/getaddrinfo.3" target="_blank">http://www.opensource.apple.com/source/Libinfo/Libinfo-222.4.12/lookup.subproj/getaddrinfo.3</a><br>
</div>
<div><br>
</div>
<div>And here's its source:</div>
<div><br>
</div>
<div><a href="http://www.opensource.apple.com/source/Libinfo/Libinfo-222.4.12/lookup.subproj/getaddrinfo.c" target="_blank">http://www.opensource.apple.com/source/Libinfo/Libinfo-222.4.12/lookup.subproj/getaddrinfo.c</a><br>
</div>
<div><br>
</div>
<div>Glancing at the source naïvely, I might see the data
race: getaddrinfo calls gai_lookupd, which reads and writes
the global static variable "gai_proc". I can't see what will
go wrong as a result of the race, but it sure LOOKS bad. =)</div>
<div><br>
</div>
<div>In the next release, version 278, the thread-safety
warning is gone from the man page:</div>
</div>
<div><br>
</div>
<div><a href="http://www.opensource.apple.com/source/Libinfo/Libinfo-278/lookup.subproj/getaddrinfo.3" target="_blank">http://www.opensource.apple.com/source/Libinfo/Libinfo-278/lookup.subproj/getaddrinfo.3</a><br>
</div>
<div><br>
</div>
<div>And getaddrinfo is largely rewritten:</div>
<div><br>
</div>
<div><a href="http://www.opensource.apple.com/source/Libinfo/Libinfo-278/lookup.subproj/getaddrinfo.c" target="_blank">http://www.opensource.apple.com/source/Libinfo/Libinfo-278/lookup.subproj/getaddrinfo.c</a><br>
</div>
<div><br>
</div>
<div>It calls a new function, "ds_getaddrinfo".
But ds_getaddrinfo still accesses the global static variable
"gai_proc"; I wonder why this is considered thread-safe now?</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Sun, Jan 3, 2016 at 12:14 AM,
Siobhan Lynch <span dir="ltr"><<a href="mailto:slynch2112@me.com" target="_blank">slynch2112@me.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">OK… try and look at the
revision histories of these three files:
<div><br>
</div>
<div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">
<b>#include</b> <b><sys/types.h></b></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">
<b>#include</b> <b><sys/socket.h></b></div>
<div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">
<b>#include</b> <b><netdb.h></b></div>
<div><br>
</div>
<div><br>
</div>
<div><b>-Trish</b></div>
<div>
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word">
<div style="color:rgb(0,0,0);letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;word-wrap:break-word"><br>
</div>
</div>
</div>
<br>
</div>
</div>
</blockquote>
</div>
<br>
</div>
<br>
<fieldset></fieldset>
<br>
</div></div><span class=""><pre>_______________________________________________
talk mailing list
<a href="mailto:talk@lists.nycbug.org" target="_blank">talk@lists.nycbug.org</a>
<a href="http://lists.nycbug.org/mailman/listinfo/talk" target="_blank">http://lists.nycbug.org/mailman/listinfo/talk</a></pre>
</span></blockquote>
<br>
</div>
<br>_______________________________________________<br>
talk mailing list<br>
<a href="mailto:talk@lists.nycbug.org">talk@lists.nycbug.org</a><br>
<a href="http://lists.nycbug.org/mailman/listinfo/talk" rel="noreferrer" target="_blank">http://lists.nycbug.org/mailman/listinfo/talk</a><br></blockquote></div><br></div>