public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug network/29717] New: getaddrinfo returns EAI_NONAME with errno set to EMFILE.
@ 2022-10-22 12:31 mpoliwczak34 at gmail dot com
2022-10-24 10:32 ` [Bug network/29717] " fweimer at redhat dot com
0 siblings, 1 reply; 2+ messages in thread
From: mpoliwczak34 at gmail dot com @ 2022-10-22 12:31 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29717
Bug ID: 29717
Summary: getaddrinfo returns EAI_NONAME with errno set to
EMFILE.
Product: glibc
Version: 2.36
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: network
Assignee: unassigned at sourceware dot org
Reporter: mpoliwczak34 at gmail dot com
Target Milestone: ---
When running out of FDs the getaddrinfo returns EAI_NONAME (instead of
EAI_SYSTEM) and it sets errno to EMFILE. The man page says that the errno is
only set it the case where getaddrinfo returns EAI_SYSTEM. I tested it also
with musl libc and it returns the correct code: EAI_SYSTEM. It seems like a bug
in glibc.
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <netdb.h>
#include <fcntl.h>
int lookup_host (const char *host) {
struct addrinfo hints, *res, *result;
int errcode;
memset (&hints, 0, sizeof (hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags |= AI_CANONNAME;
errcode = getaddrinfo (host, NULL, &hints, &result);
if (errcode != 0) {
if (errcode == EAI_SYSTEM) {
printf("eai system\n");
perror("getaddrinfo");
return -1;
}
printf("not eai system\n");
perror("getaddrinfo");
return -1;
}
freeaddrinfo(result);
return 0;
}
int main (void) {
for (int i = 0; i < 100; i++) {
open("/tmp",O_WRONLY|O_TMPFILE,0640);
}
char* inbuf = "go.dev";
lookup_host(inbuf);
}
Glibc:
[mateusz@arch code ]$ gcc main.c && bash -c 'ulimit -n 50 && ./a.out'
not eai system
getaddrinfo: Too many open files
Musl libc:
[mateusz@arch code ]$ musl-gcc main.c && bash -c 'ulimit -n 50 && ./a.out'
eai system
getaddrinfo: No file descriptors available
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug network/29717] getaddrinfo returns EAI_NONAME with errno set to EMFILE.
2022-10-22 12:31 [Bug network/29717] New: getaddrinfo returns EAI_NONAME with errno set to EMFILE mpoliwczak34 at gmail dot com
@ 2022-10-24 10:32 ` fweimer at redhat dot com
0 siblings, 0 replies; 2+ messages in thread
From: fweimer at redhat dot com @ 2022-10-24 10:32 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=29717
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fweimer at redhat dot com
See Also| |https://sourceware.org/bugz
| |illa/show_bug.cgi?id=22041
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-10-24 10:32 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-22 12:31 [Bug network/29717] New: getaddrinfo returns EAI_NONAME with errno set to EMFILE mpoliwczak34 at gmail dot com
2022-10-24 10:32 ` [Bug network/29717] " fweimer at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).