Tcl Source Code

View Ticket
Login
Ticket UUID: 91466985995db6b505c415322b8090a5754f2dc3
Title: NetBSD's gethostbyname_r() incompatible with Tcl usage
Type: Bug Created on: 2015-11-01 21:35:28
Submitter: emiliano Assigned to: nobody
Subsystem: 52. Portability Support Severity: Critical
Priority: 5 Medium Last modified: 2019-10-02 13:40:40
Status: Closed Closed by: krytarowski
Resolution: None Closed on: 2019-10-02 13:40:40
Version: trunk
Description:
On NetBSD, gethostbyname_r is detected but the function is incompatible
with Tcl usage, so at least on NetBSD-7 [info hostname] crashes.
Attached patch solves the issue.
User Comments:
emiliano added on 2016-07-07 12:57:36:
More evidence that gethostbyname_r() is unsupported on NetBSD:

http://mail-index.netbsd.org/netbsd-users/2016/06/30/msg018651.html

dkf added on 2016-07-09 08:37:26:
Is there a reason for that platform not using getaddrinfo()?

dkf added on 2016-07-09 08:40:30:

By which I mean "why don't we switch to using getaddrinfo() there as well as for actually creating sockets?" After all, we've already got the machinery largely there in tclIOSock.c...


gustafn2 added on 2016-07-21 12:13:57:
my 5ct: i would think that in cases, where HAVE_GETADDRINFO is defined, one should use getaddrinfo() instead of gethostbyname*(). If there are really systems in use, which do not HAVE_GETADDRINFO, these can fallback to the GETHOSTBYNAME machinery.

gustafn2 added on 2016-07-21 12:20:09:

... we do this in NaviServer, see e.g. bitbucket/naviserver/nsd/dns.c#372


gustafn2 added on 2016-07-26 10:13:03:
I've added a patch replacing all occurrences of gethostbyname_r() by an appropriate call of getaddrinfo(). Actually, the definition of TclpGetHostByName() could/should be dropped, when HAVE_GETADDRINFO is defined (i am not sure, what the policy in tcl-core concerning Tclp* calls is). I would recommend to drop TclpGetHostByName(), since this returns a partial struct hostent, which makes mostly sense in connection with gethostbyname*().

emiliano added on 2017-05-29 15:30:34:
From a fresh update of Tcl trunk (2017-05-29), compiled with default options:

% info hostname
cabernet.vinotinto.com.ar
% info patchlevel
8.7a0
% uname -a
NetBSD cabernet.vinotinto.com.ar 7.1 NetBSD 7.1 (GENERIC.201703111743Z) i386

So this ticket can be closed.

The issue of using non-standard interfaces (gethostbyname_r) when a standard one can be used (getaddrinfo) should be addressed to avoid reintroducing these type of
bugs

krytarowski added on 2019-10-02 13:40:40:
Fixed with https://core.tcl-lang.org/tcl/info/16768d65f0

Attachments: