www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18276] New: Inconsistent assumption about result of

https://issues.dlang.org/show_bug.cgi?id=18276

          Issue ID: 18276
           Summary: Inconsistent assumption about result of
                    InternetHost.getHostByName
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: dlang.org bregalad.de

One of the InternetAddress constructors
https://github.com/dlang/phobos/blob/v2.078.0/std/socket.d#L1563
assumes that a succesful InternetHost.gethostbyname call results in at least
one entry in addrList.

The implementation of InternetHost.populate, which fills addrList:
https://github.com/dlang/phobos/blob/v2.078.0/std/socket.d#L704-L716
has a case where addrList remains null.


This at least *looks* like a problem; either the addrList = null case in
populate should never be reached, or the assumption in the InternetAddress
constructor is invalid, right?


I came to look at this because I had code which tripped an out of range
exception on https://github.com/dlang/phobos/blob/v2.078.0/std/socket.d#L1563 .
 In my case this may have been due to use of gethostbyname by a third party
(non-D) library, which obviously didn't respect the phobos mutex around
gethostbyname.
My workaround is currently to not use InternetAddress at all.

gethostbyname is deprecated in any case (=>
https://issues.dlang.org/show_bug.cgi?id=15424), so maybe a rewrite or
deprecation here is in order anyway?

--
Jan 22 2018