[SERVER-1417] hostbyname() uses gethostbyname() function, which is not thread-safe on Linux Created: 13/Jul/10  Updated: 28/Jun/12  Resolved: 15/Jul/10

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 1.4.4
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Kazuki Ohta Assignee: Mathias Stearn
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux


Operating System: Linux
Participants:

 Description   

hostbyname() in src/util.cpp uses gethostbyname() function, which is not thread-safe on Linux. Should be gethostbyname_r(); This could return the invalid results, and sometimes causes SEGV in ScopedDbConnection.

This is only for the current stable version. Not for the git HEAD, because it already changed to use getaddrinfo().

Please close the issue if this is not important because this was fixed in HEAD.



 Comments   
Comment by Mathias Stearn [ 15/Jul/10 ]

The call to gethostbyname is protected by a lock: http://github.com/mongodb/mongo/blob/v1.4/util/sock.cpp#L30-42

If you have a stacktrace that shows that gethostbyname is SEGVing then please reopen and attach.

Generated at Thu Feb 08 02:56:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.