From owner-freebsd-bugs Wed Dec 17 09:30:05 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id JAA26394 for bugs-outgoing; Wed, 17 Dec 1997 09:30:05 -0800 (PST) (envelope-from owner-freebsd-bugs) Received: (from gnats@localhost) by hub.freebsd.org (8.8.7/8.8.7) id JAA26387; Wed, 17 Dec 1997 09:30:02 -0800 (PST) (envelope-from gnats) Date: Wed, 17 Dec 1997 09:30:02 -0800 (PST) Message-Id: <199712171730.JAA26387@hub.freebsd.org> To: freebsd-bugs Cc: From: Bruce Evans Subject: Re: bin/5306: gethostbyname() returns herror "Unknown host" on well known hosts Reply-To: Bruce Evans Sender: owner-freebsd-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk The following reply was made to PR bin/5306; it has been noted by GNATS. From: Bruce Evans To: bde@zeta.org.au, chris@netmonger.net, freebsd-gnats-submit@freebsd.org, robert@superior.net Cc: Subject: Re: bin/5306: gethostbyname() returns herror "Unknown host" on well known hosts Date: Thu, 18 Dec 1997 04:23:38 +1100 >I don't know whether the gethostbyname() problem Robert is having is >related to PR 3622, but I think there is a problem with the default >login.conf. > >I had to lower openfiles settings to 256 because having it larger >breaks select(). It's been a while, so I'm a bit fuzzy on the details, >but I do remember that it was causing rxvt to fail.. a quick perusal >of the rxvt source indicates that it does: It breaks buggy applications. >I believe that it ends up obtaining the 1024 that was defined in login.conf, >but the FD_SETSIZE in sys/types.h is defined as 256. IIRC, select() bombs >out when nfds is > 256. Naive use of the FD_* macros doesn't work if nfds > FD_SETSIZE. The application should know about this and either not supports fd's >= FD_SETSIZE, or handle them somehow. The documented way is to #define FD_SETSIZE before including . The networking libraries use a more flexible way. >I suppose I should test this rather than just make the claim. Try this: > >#include >#include >#include >#include >#include > >void testselect(int num) >{ > fd_set fds; > struct timeval tv = {0, 0}; > > printf("testing select(%d,...)\n", num); > FD_ZERO(&fds); > if (select(num, &fds, &fds, &fds, &tv) < 0) { > perror("select()"); > } If nfds > FD_SETSIZE, in FreeBSD-2.2.0 and later versions, select() will probably succeed and scribble on the stack beyond the end of fds. In earlier versions, it rejects the request if nfds > 256. FD_SETSIZE happens to be 256 in 2.2.5 and 1024 in -current. Programs should not depend on this (but many probably do :-(). Bruce